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

Question about behaviour of git-checkout --patch option

From
MBMerlin Büge <toni@bluenox07.de>
Date
May 25, 2020, 20:11 UTC
Message-ID
<20200525221100.31d36d4d.toni@bluenox07.de>
Hi all!

I have a question about the behaviour of the git-checkout --patch/-p option.

I have a small local git repository containing empty and non-empty files. I wanted to replicate it in another directory and did the following:

	cd <target_dir>
	git init
	git remote add origin <origin_dir>
	git fetch
	git branch --track master origin/master
	git checkout master .

This works like expected, I end up with a 1:1 copy of the original worktree, including empty files. However, if I include the -p option in the last step:

	git checkout -p master .

... I correctly get asked for any non-empty files/hunks if I want to apply them - but not for empty ones. It would just display e.g.

	diff --git b/emptyfile a/emptyfile
	new file mode 100644
	index 0000000..e69de29
and then skip over it, asking for the next non-empty hunk.
Why does it skip over empty hunks?
Thanks!
-- 
Merlin Büge
Next: Jeff King
Message 1 of 7 in “Question about behaviour of git-checkout --patch option”
  1. Merlin BügeMay 25, 2020
  2. Jeff KingMay 27, 2020
  3. Jeff KingMay 27, 2020
  4. Merlin BügeMay 27, 2020
  5. Johannes SchindelinMay 27, 2020
  6. Merlin BügeMay 27, 2020
  7. Johannes SchindelinMay 27, 2020

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.