git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: for newbs = little exercise / tutorial / warmup for windows and other non-sophisticated new Git users :-)

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Dec 30, 2008, 23:29 UTC
Message-ID
<alpine.LNX.1.00.0812301730440.19665@iabervon.org>
In-Reply-To
<gje4ff$ip6$4@ger.gmane.org>
On Tue, 30 Dec 2008, Zorba wrote:
Show 5 quoted lines
> > good news, use "git checkout versionA", not "git checkout versionA ."
> > (so, use it wihtout the dot), and you should be back in working order.
> 
> ** yes but I don't get the files copied out into the tree which is all my 
> little heart ever desired

So in order for this to make sense, you're going to need to know a little tiny bit about branches (which, fortunately, is trivial compared to branches in most SCMs). In git, a branch is a mutable pointer to a commit, which is the latest commit on the branch (all of the earlier commits on the branch are linked off of the latest one; each commit points to the one before). By default, you have a branch called "master", and that's the branch that your series of commands builds up. Now, at any given time, you can have a "current branch" (a.k.a. HEAD), which is the branch that you'd put a new commit on if you made one. "master" is your current branch while you're building up that history.

When you want to navigate the history, however, you want to leave all of the branches alone and take your working directory into the history. This is known as being on "(no branch)" or, as Zippy would say, having a "detached HEAD". This way you leave the "master" branch pointing to versionD, which is, after all, the latest commit, while you get yourself an old version. You can do this with:

$ git checkout versionA

because you've made a tag for it. In order to get back to developing (as opposed to looking at history), you use:

$ git checkout master
(because "master" is your branch, while "versionA" is a tag).

If you're on master, either after checking it out explicitly or before you've used checkout at all, doing:

$ git checkout versionA .

with *not* switch you away from the current branch, but will get the contents of "." from versionA into your index and working directory, and it doesn't remove things that you have currently.

Show 7 quoted lines
> ** LOL, I have to admit I am enjoying this though, even if its driving me 
> slightly potty - haha
> I didn't write these early versions so I just wanna have them around to 
> rollback to if I end up hacking the thing to bits.
> But you're right - chances of using are slim - but you could say that about 
> every version sitting in any given SCM repo.
> Thats why we have SCM, and why we insure our cars etc etc. :-) 

Even if you never rolling back to it, it's useful for figuring out what you did when.

	-Daniel
*This .sig left intentionally blank*
Previous: Jeff WhitesideNext: Zorba
Message 14 of 21 in “for newbs = little exercise / tutorial / warmup for windows and other non-sophisticated new Git users :-)”
  1. ZorbaDec 27, 2008
  2. ZorbaDec 28, 2008
  3. Jeff WhitesideDec 29, 2008
  4. ZorbaDec 30, 2008
  5. Jeff WhitesideDec 30, 2008
  6. ZorbaDec 30, 2008
  7. Sitaram ChamartyDec 30, 2008
  8. ZorbaDec 30, 2008
  9. ZorbaDec 30, 2008
  10. ZorbaDec 30, 2008
  11. Jeff WhitesideDec 30, 2008
  12. ZorbaDec 30, 2008
  13. Jeff WhitesideDec 30, 2008
  14. Daniel BarkalowDec 30, 2008
  15. ZorbaDec 31, 2008
  16. ZorbaDec 30, 2008
  17. Boyd Stephen Smith Jr.Dec 30, 2008
  18. Boyd Stephen Smith Jr.Dec 30, 2008
  19. Boyd Stephen Smith Jr.Dec 30, 2008
  20. Sitaram ChamartyDec 31, 2008
  21. Daniel BarkalowDec 30, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.