Skip to contentSkip to conversation

git am fails to add new files

DISCUSSION Thomas Koch 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi,

I'm using GIT on Debian unstable (1.6.6.1). When applying patches I created with git format-patch and applying them afterwards with git am, this fails with every patch that adds a new file.
Is there any option I forgot to give to git am? Or is this a bug.

Best regards,

Thomas Koch, http://www.koch.ro

#1 lore raw
Quoted 4 lines · Thomas Koch

I'm using GIT on Debian unstable (1.6.6.1). When applying patches I created with git format-patch and applying them afterwards with git am, this fails with every patch that adds a new file.
Is there any option I forgot to give to git am? Or is this a bug.

No, it should just work. However, I can't replicate your problem using the following script:

mkdir repo && cd repo && git init &&
echo 1 >file-1 && git add . && git commit -m one && echo 2 >file-2 && git add . && git commit -m two && git format-patch -1 --stdout >patch &&
git reset --hard HEAD^ &&
echo Confirm that file-2 is gone... &&
! grep . file-2 &&
git am patch &&
echo Confirm that file-2 is back... &&
grep . file-2

So perhaps there is something else going on. Can you provide us with samples of the patches that fail to apply? What does "git am" say when it tries to apply?

-Peff