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
Junio C Hamano <gitster@pobox.com>
Date
Dec 31, 2008, 04:48 UTC
Message-ID
<7v7i5hymp7.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<200812302141.02248.bss@iguanasuicide.net>
"Boyd Stephen Smith Jr." <bss@iguanasuicide.net> writes:
Show 9 quoted lines
> On Tuesday 2008 December 30 20:30:46 Conor Rafferty wrote:
>> MERCURIAL:
>>
>> Update
>> hg update [-C] [-d DATE] [[-r] REV]
>
> Which is the role of "git checkout <branch>"
>
> "git checkout <branch> <paths>" is similar to "hg revert -r <branch> <paths>", 
No it is not.
The form of the command is makes this request:
    Please look into that named <tree-ish>, and check out the named
    <paths> out of it to my work tree.  Because the reason I want them in
    my work tree is so that I can include them as part of the next commit
    I am preparing to create in the index, please update these paths in my
    index while at it.

After working for some time on top of the current HEAD to make changes to existing files in "lib/" directory, if you notice that none of your changes in the directory does not make any sense, you may rather want to start over from the version that you began with. In such a case, you would make the above request with <tree-ish> equal to HEAD and <paths> equal to "lib", i.e.

    git checkout HEAD lib

and as the end result you may be able to achieve "reverting my crappy changes to all of the files in lib/".

HOWEVER.

Read what the above request says carefully again, and think about what would happen to a path that exists in the work tree but not in the named <tree-ish>.

In other words, what would happen to a new file you added since you started working on top of HEAD?

See?

A new file that you added in lib/ directory since you started working will not be molested in any way, because they do not even exist in the <tree-ish>.

If you think "git checkout <tree-ish> <paths>" has anything to do with reverting, you will keep confusing yourself. The command is "checking out the named paths out of the named tree", and absense of a file is not something that is checked out by this operation.

Previous: Boyd Stephen Smith Jr.Next: Daniel Barkalow
Message 3 of 6 in “RE: for newbs = little exercise / tutorial / warmup for windows and other non-sophisticated new Git users :-) [Scanned]”
  1. Conor RaffertyDec 31, 2008
  2. Boyd Stephen Smith Jr.Dec 31, 2008
  3. Junio C HamanoDec 31, 2008
  4. Daniel BarkalowDec 31, 2008
  5. Junio C HamanoDec 31, 2008
  6. Boyd Stephen Smith Jr.Dec 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.