Git doesn't always add files to a commit (amend)
- From
Yuri Kanivetsky <yuri.kanivetsky@gmail.com>
- Date
- Jul 4, 2016, 13:50 UTC
- Message-ID
- <CAMhVC3Y9iT9X=JbB5tguXm8MRX4v2fDEqMwrMuDR6TD2+2+HLQ@mail.gmail.com>
Hi,
When intent to add a directory is made (`git add -N`), and then contents of any but the first file is staged, `git commit -v --amend` doesn't add it to the commit, see for yourself:
#!/usr/bin/env bash
set -eu
rm -rf 1
mkdir 1
cd 1
git init
echo 1 > 1 && git add 1 && git commit -m 1
mkdir 2
echo 2/1 > 2/1
echo 2/2 > 2/2
git add -N 2
# git add 2/1 # this file is added
git add 2/2 # as opposed to this one
git commit --amend -m 1
git --no-pager log -p
git reset
git --no-pager statusI'm running git-2.9.0.
Regards, Yuri