# RE: for newbs = little exercise / tutorial / warmup for windows and other non-sophisticated new Git users :-) [Scanned]

3 messages from 2008-12-30 to 2008-12-31. Participants: Conor Rafferty, Boyd Stephen Smith Jr., Sitaram Chamarty.
Thread: https://gitlist.dev/t/16933

## Conor Rafferty, 2008-12-30 22:39

Subject: RE: for newbs = little exercise / tutorial / warmup for windows and other non-sophisticated new Git users :-) [Scanned]
Message-ID: <BB5F02FD3789B54E8964D38D6775E718242D33@ALTMORE-SVR.altmore.local>
URL: https://gitlist.dev/e/BB5F02FD3789B54E8964D38D6775E718242D33%40ALTMORE-SVR.altmore.local

```
Whoa there Stevey, I'm a windows user, don't forget

I mighta had a chance at following this 10-12 years ago when last I did
some scripting, but not now

Its very generous of you to go to all this bother and I'm mighty
grateful. 

However if this is what its gonna take to get what I want, then Im'
outta here.

Getting a snapshot on the filesystem, in terms of a directory tree (not
a reference to, representation of etc etc. but a real life directory
tree, files and folders that you can actually interact with - build,
edit etc.), of a past version is a basic operation in my book.
Even in clearcase this was a cinch.

Is there anyone who can see anyway to do this simply, without a script,
without creating a branch ?

Personally I suspect "$ git checkout <version> ." is what should be
doing this (I have confidence in saying this because it seems to want to
do this, and does it right at least half the time). But no-one wants to
admit to the remotest possibility that it might be off ....

In any case, a bunch of smart guys like you should be able to knock this
functionality together in hours, if you put your mind to it.

I know you guys have put a lot into this project and for many of you it
defines who you are 
- but if you want ppl out there in the user world to take this stuff on,
its gotta work for them 

<END>impassioned plea</>

-----Original Message-----
From: Boyd Stephen Smith Jr. [mailto:bss@iguanasuicide.net] 
Sent: 30 December 2008 22:17
To: Conor Rafferty
Cc: git@vger.kernel.org
Subject: Re: for newbs = little exercise / tutorial / warmup for windows
and other non-sophisticated new Git users :-) [Scanned]

On Tuesday 2008 December 30 15:49:22 Boyd Stephen Smith Jr. wrote:
> On Tuesday 2008 December 30 15:27:33 you wrote:
> > conorr@KINKLADZE /w/GITPLATFORM/swproj $ git status # On branch 
> > master nothing to commit (working directory clean)
> >
> > conorr@KINKLADZE /w/GITPLATFORM/swproj $ git checkout versionA .
> >
> > conorr@KINKLADZE /w/GITPLATFORM/swproj $ ls ABC.txt  AC.txt
> >
> > conorr@KINKLADZE /w/GITPLATFORM/swproj $ rm *.*
> >
> > conorr@KINKLADZE /w/GITPLATFORM/swproj $ git checkout versionB .
> >
> > conorr@KINKLADZE /w/GITPLATFORM/swproj $ ls ABC.txt  AC.txt  BC.txt
>
> Not a bug.  git checkout <commit> <paths> does not delete files by
design.
> Try using "git checkout versionB" instead (no paths specified), and it

> will properly remove AC.txt from your working tree as well as warning 
> you that "You're Doing It Wrong" (tm).

This may be what you want:
(commands)
mkdir test && cd test && git init &&

echo 'ABC' > ABC.txt && echo 'AC' > AC.txt && echo 'BC' > BC.txt && echo
'C' > C.txt &&

find -name '*C*' -print0 | xargs -r0 -- git add -- && git commit -m '"C"
files.' && git branch versionC master &&

git checkout -b versionA master &&
find -type f -not -wholename '*.git*' -not -name '*A*' -print0 | \
	xargs -r0 -- git rm -- &&
git commit -m 'Removed non-"A" files.' &&

git checkout -b versionB &&
find -type f -not -wholename '*.git*' -not -name '*B*' -print0 | \
	xargs -r0 -- git rm -- &&
git commit -m 'Removed non-"B" files.' &&

git checkout -b versionD master &&
find -type f -not -wholename '*.git*' -not -name '*D*' -print0 | \
	xargs -r0 -- git rm -- && git commit -m 'Removed non-"D" files.'
&&

git checkout master && git branch -v --abbrev=4 && ls -l && git checkout
versionA && ls -l && git checkout versionB && ls -l && git checkout
versionC && ls -l && git checkout versionD && ls -l

(output)
/home/bss/test
Initialized empty Git repository in /home/bss/test/.git/ Created initial
commit 8dbf3a1: All files.
 4 files changed, 4 insertions(+), 0 deletions(-)  create mode 100644
ABC.txt  create mode 100644 AC.txt  create mode 100644 BC.txt  create
mode 100644 C.txt Switched to a new branch "versionA"
rm 'BC.txt'
rm 'C.txt'
Created commit a06e10c: Removed non-"A" files.
 2 files changed, 0 insertions(+), 2 deletions(-)  delete mode 100644
BC.txt  delete mode 100644 C.txt Switched to a new branch "versionB"
rm 'AC.txt'
Created commit 2029ca2: Removed non-"B" files.
 1 files changed, 0 insertions(+), 1 deletions(-)  delete mode 100644
AC.txt Switched to a new branch "versionD"
rm 'ABC.txt'
rm 'AC.txt'
rm 'BC.txt'
rm 'C.txt'
Created commit 1793ba0: Removed non-"D" files.
 4 files changed, 0 insertions(+), 4 deletions(-)  delete mode 100644
ABC.txt  delete mode 100644 AC.txt  delete mode 100644 BC.txt  delete
mode 100644 C.txt Switched to branch "master"
* master   8dbf "C" files.
  versionA a06e Removed non-"A" files.
  versionB 2029 Removed non-"B" files.
  versionC 8dbf "C" files.
  versionD 1793 Removed non-"D" files.
total 16
-rw-r--r-- 1 bss users 4 2008-12-30 16:10 ABC.txt
-rw-r--r-- 1 bss users 3 2008-12-30 16:10 AC.txt
-rw-r--r-- 1 bss users 3 2008-12-30 16:10 BC.txt
-rw-r--r-- 1 bss users 2 2008-12-30 16:10 C.txt Switched to branch
"versionA"
total 8
-rw-r--r-- 1 bss users 4 2008-12-30 16:10 ABC.txt
-rw-r--r-- 1 bss users 3 2008-12-30 16:10 AC.txt Switched to branch
"versionB"
total 4
-rw-r--r-- 1 bss users 4 2008-12-30 16:10 ABC.txt Switched to branch
"versionC"
total 16
-rw-r--r-- 1 bss users 4 2008-12-30 16:10 ABC.txt
-rw-r--r-- 1 bss users 3 2008-12-30 16:10 AC.txt
-rw-r--r-- 1 bss users 3 2008-12-30 16:10 BC.txt
-rw-r--r-- 1 bss users 2 2008-12-30 16:10 C.txt Switched to branch
"versionD"
total 0
-- 
Boyd Stephen Smith Jr.                     ,= ,-_-. =. 
bss@iguanasuicide.net                     ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' 
http://iguanasuicide.net/                      \_/     

```

## Boyd Stephen Smith Jr., 2008-12-31 00:12

Subject: Re: for newbs = little exercise / tutorial / warmup for windows and other non-sophisticated new Git users :-) [Scanned]
Message-ID: <200812301812.12759.bss@iguanasuicide.net>
URL: https://gitlist.dev/e/200812301812.12759.bss%40iguanasuicide.net
In-Reply-To: <BB5F02FD3789B54E8964D38D6775E718242D33@ALTMORE-SVR.altmore.local>

```
On Tuesday 2008 December 30 16:55:38 Conor Rafferty wrote:
> Whoa there Stevey, I'm a windows user, don't forget

I just assumed you were also a git user. ;)

> However if this is what its gonna take to get what I want, then Im'
> outta here.

You aren't being entirely clear about what you want.

> Getting a snapshot on the filesystem, in terms of a directory tree (not
> a reference to, representation of etc etc. but a real life directory
> tree, files and folders that you can actually interact with - build,
> edit etc.), of a past version is a basic operation in my book.
> Even in clearcase this was a cinch.

Well, there's a lot of things about UNIX and Windows directories that git 
doesn't store.  It'll restore the contents, sure, but not the permissions, 
timestamps, etc.  However git also stores the *history*, if you don't care 
about that, tarballs or zip archives might actually be a better system for 
your purposes.

But, each time you commit you've made some snapshot (completeness depends on 
what you staged with git add and friends) and recorded that snapshot as 
a "later point in time" from the last snapshot you "git checkout"ed.  That 
new object (a "commit") can be identified by it's sha1.  It holds a sha1 of 
all it's parents (also "commits") and of the snapshot alone (a "tree").

You've also figured out how to use lightweight tags to give names (other than 
their sha1) to your commits.

> Is there anyone who can see anyway to do this simply, without a script,
> without creating a branch ?

Branching is arguably easier than tagging, and probably what you want to do 
instead.  Sure, branches are mutable, but unsigned tags are also fairly 
mutable.

> Personally I suspect "$ git checkout <version> ." is what should be
> doing this.

I'm pretty sure what you want is "git checkout <version>" not "git checkout 
<version> <paths>".  They operate differently.  Modern git can checkout a 
lightweight tag, but it's going to warn you that it not what you want.

> - but if you want ppl out there in the user world to take this stuff on,
> its gotta work for them

Maybe others do, but I don't really see git as an end-user tool.  It's a 
developer tool and rightly demands a bit of RTFMing before using it 
effectively.

What you seem to *really* want is a bunch of named trees without any 
relationship between one another.  IMHO, git isn't really good at that (but 
only because it demands to do more).  A directory full of tarballs / 
zip-archives and a couple of scripts you wrote yourself (extract.sh; 
name-and-save.sh) would probably be better.

I admit that there seems to be quite a niche for some sort of trivially usable 
VCS, but it needs to be good at merging spreadsheets, compressed/binary XML, 
presentations/decks, and other things not-text, have a pretty GUI, and run 
securely over TCP/IP ports that no one is willing to block.  It will probably 
be next to useless for doing what git was initially designed for (managing 
Linux kernel patches).
-- 
Boyd Stephen Smith Jr.                     ,= ,-_-. =. 
bss@iguanasuicide.net                     ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' 
http://iguanasuicide.net/                      \_/     

```

## Sitaram Chamarty, 2008-12-31 02:22

Subject: Re: for newbs = little exercise / tutorial / warmup for windows and other non-sophisticated new Git users :-) [Scanned]
Message-ID: <slrnglllr8.kdq.sitaramc@sitaramc.homelinux.net>
URL: https://gitlist.dev/e/slrnglllr8.kdq.sitaramc%40sitaramc.homelinux.net
In-Reply-To: <BB5F02FD3789B54E8964D38D6775E718242D33@ALTMORE-SVR.altmore.local>

```
On 2008-12-30, Conor Rafferty <conor.rafferty@altmore.co.uk> wrote:

[re-arranged some of the quotes; it's not in the same order
as in your original email...]

> Even in clearcase this was a cinch.

Hey there's no need to use swear words ;-)

> Is there anyone who can see anyway to do this simply, without a script,
> without creating a branch ?

You'll have to unlearn this resistance to creating branches.
I've never used clearcase, but people tell me it is
expensive to create branches and/or merge them later --
almost a project in itself perhaps?

In git, however, creating a branch is as cheap as creating a
tag, so why not go with the flow until you're a little more
familiar with it?

> Personally I suspect "$ git checkout <version> ." is what should be

leave out the "." is all you needed to do.

> doing this (I have confidence in saying this because it seems to want to
> do this, and does it right at least half the time). But no-one wants to
> admit to the remotest possibility that it might be off ....

Because it's not off :-)  You're using an unusual construct
that is not often used.  (I've done path checkout of one or
a few files, but not the whole "." ever).  So it took people
time to analyse what was happening -- such as suggesting you
use "git ls-files -s" to see what's in the index at each
stage.

May I ask where you got the idea that "." is needed?  We
need to fix that source too ;-)

> In any case, a bunch of smart guys like you should be able to knock this
> functionality together in hours, if you put your mind to it.

> I know you guys have put a lot into this project and for many of you it
> defines who you are 
> - but if you want ppl out there in the user world to take this stuff on,
> its gotta work for them 

While I applaud your efforts to try and understand
everything in one long weekend, you'd have more fun if you
spaced it out a bit :-)

I'll also say that "ppl out there in the user world" will
not experiment the way you have -- they'll follow a basic
set of commands that work.

They'll even (gasp!) use the GUI.  Believe me the GUIs are
pretty nice, though it won't let you checkout a tag (you can
checkout a branch, but not a tag -- because this gets you a
detached head which is a little too advanced for normal
folks I guess).

In other words, you're combining newbie and expert too
fast...

Finally, I heartily recommend reading the following article:
http://thedailywtf.com/Articles/Happy_Merge_Day!.aspx

If the hints in the article are not enough for you to figure
out this is about clearcase read the comments :-)

```
