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 :-) [Scanned]

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Dec 31, 2008, 03:49 UTC
Message-ID
<alpine.LNX.1.00.0812302236190.19665@iabervon.org>
In-Reply-To
<alpine.LNX.1.00.0812302143210.19665@iabervon.org>
On Tue, 30 Dec 2008, Daniel Barkalow wrote:
Show 16 quoted lines
> On Wed, 31 Dec 2008, Conor Rafferty wrote:
> 
> > -----Original Message-----
> > wtf is wrong with
> > 
> > git checkout <something>
> > 
> > ??
> > 
> > ** It doesn't reliably put the files that were in that revision into the
> > working directory - a fairly major flaw, for what I'm using SCM for (and
> > 80% of the market IMHO)
> 
> It certainly does for me; I rely on it pretty much constantly. Can you 
> give a sequence of commands (ideally the whole sequence from the "git 
> init") that leads to a difference?
Actually, I know what you must be doing:

$ git tag versionD $ git checkout versionA (versionA in the working directory) $ rm *.* (versionA with ABC.txt and AC.txt deleted) $ git checkout versionB (versionB with ABC.txt and AC.txt deleted)

If you've made any changes (including deleting files), "git checkout" (no pathes) will preserve them. On the other hand, it will remove files that are in the commit you're leaving and not in the commit you're going to. So just don't remove the working directory files and you should be all set.

In order to get them back if you have removed them, you can do:
$ git checkout .

This will discard all of the changes you've made only to the working directory; i.e., it'll recover the deleted files. You should also try "git status" whenever anything's mysterious, because it will tell you what's going on.

	-Daniel
*This .sig left intentionally blank*
Previous: Daniel BarkalowNext: Zorba
Message 5 of 11 in “RE: for newbs = little exercise / tutorial / warmup for windows and other non-sophisticated new Git users :-) [Scanned]”
  1. Conor RaffertyDec 31, 2008
  2. Jeff WhitesideDec 31, 2008
  3. Boyd Stephen Smith Jr.Dec 31, 2008
  4. Daniel BarkalowDec 31, 2008
  5. Daniel BarkalowDec 31, 2008
  6. ZorbaDec 31, 2008
  7. Sitaram ChamartyDec 31, 2008
  8. Daniel BarkalowDec 31, 2008
  9. Sitaram ChamartyDec 31, 2008
  10. ZorbaDec 31, 2008
  11. Sitaram ChamartyDec 31, 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.