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

Re: My first git success [not quite]

From
Junio C Hamano <junkio@cox.net>
Date
Jan 14, 2006, 20:49 UTC
Message-ID
<7vbqyefsbc.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<dqbnl1$3si$1@sea.gmane.org>
walt <wa1ter@myrealbox.com> writes:
Show 11 quoted lines
> Linus Torvalds wrote:
> [...]
>> Now, what happens is that when you change branches with a dirty tree, the 
>> "git checkout" will do one of two things:
>> 
>>  - if the dirty files are _identical_ in both branches...
>
> I'm sorry to be quibbling over semantics, truly I am!  But here
> is my confusion:  if modified-but-uncommitted (hence dirty) files
> are not associated with *any* branch, then how could 'dirty' files
> be 'in' both branches (or 'in' any branch at all)?

"If the paths that you have dirty are the same in both branches".

That is:
* "master" branch has Makefile file, as taken from git.git
* "my-work" branch was made out of "master" branch, but
  has not modified Makefile file.
	git-diff-tree master my-work Makefile
  would yield nothing.
* You are on "master" branch.  You have added a new target to
  your Makefile in the working tree and the path is dirty.
Then:
	git checkout my-work

would notice that the path "Makefile" are identical between two branches "master" you are switching from and "my-work" you are switching to. The "Makefile" in your working tree does not match either tree, but that difference is carried over while switching branches.

As Linus mentioned, with '-m' flag to "git checkout", it can merge your local modifications even when "master" and "my-work" disagrees on "Makefile" in this example.

        
Previous: waltNext: Linus Torvalds
Message 13 of 15 in “My first git success”
  1. waltJan 13, 2006
  2. Linus TorvaldsJan 13, 2006
  3. Randal L. SchwartzJan 13, 2006
  4. Junio C HamanoJan 13, 2006
  5. Peter EriksenJan 13, 2006
  6. waltJan 14, 2006
  7. seanJan 14, 2006
  8. waltJan 14, 2006
  9. Randal L. SchwartzJan 14, 2006
  10. Junio C HamanoJan 14, 2006
  11. Linus TorvaldsJan 14, 2006
  12. waltJan 14, 2006
  13. Junio C HamanoJan 14, 2006
  14. Linus TorvaldsJan 14, 2006
  15. Junio C HamanoJan 15, 2006

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.