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

"git pull" throws away dirty state

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Mar 16, 2008, 18:08 UTC
Message-ID
<alpine.LFD.1.00.0803161055510.3020@woody.linux-foundation.org>

Ok, this is distressing, and I suspect it's another bug of mine due to unpack-trees changes, but before I delve into it deeper I thought I'd report it here and see if others see it too, and maybe it's due to something else..

I'm used to having dirty state in my tree, and still being able to do a lot of my normal work, very much including doing pulls from others. I expect that if the dirty state isn't relevant to the merge, it wil just remain, with a message like

	xyzzy: needs update
	Merge made by recursive.
and then after the merge my changes to xyzzy are still there.

That doesn't seem to work any more. The merge is successful, but it also updated the working tree, overwriting my dirty state!

Appended is a test-script for this behaviour, and I get:
	Before merge:
	diff --git a/a b/a
	index e965047..eacb93d 100644
	--- a/a
	+++ b/a
	@@ -1 +1,2 @@
	 Hello
	+Hi there
	a: needs update
	Merge made by recursive.
	 b |    1 +
	 1 files changed, 1 insertions(+), 0 deletions(-)
	After merge:
with the afte-merge diff being empty.
		Linus

--- #!/bin/sh

rm -rf test-repo mkdir test-repo cd test-repo

git init echo Hello > a echo Hi > b git add a b git commit -m "Initial commit"

git checkout -b newbranch echo Hullo >> b git commit -m "Change b in 'newbranch'" b

git checkout master echo New file > c git add c git commit -m "Add new file"

echo Hi there >> a echo Before merge: git diff git pull . newbranch echo After merge: git diff

Next: Linus Torvalds
Message 1 of 11 in “"git pull" throws away dirty state”
  1. Linus TorvaldsMar 16, 2008
  2. Linus TorvaldsMar 16, 2008
  3. Nicolas PitreMar 16, 2008
  4. Junio C HamanoMar 16, 2008
  5. Junio C HamanoMar 16, 2008
  6. Don't update unchanged merge entriesLinus Torvalds, Mar 16, 2008
  7. Daniel BarkalowMar 16, 2008
  8. Linus TorvaldsMar 16, 2008
  9. Daniel BarkalowMar 16, 2008
  10. Linus TorvaldsMar 16, 2008
  11. Junio C HamanoMar 16, 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.