背景
最近我遇到了一个问题,即在合并期间意外未合并文档文件,导致文件丢失。
由于某种原因,我弄错了合并操作,并且实际上删除了该文件(以及其他几个文件),因为我忘记它们的存在。
现在我想查看我的历史记录,看看是否有其他合并出了问题。
重现问题
git init
echo "file a" > a
git add a
git commit -m "file a added"
git checkout -b branch_c
echo "file c" > c
git add c
git commit -m "file c added"
git checkout master
git checkout -b branch_b
echo "file b" > b
git add b
git commit -m "file b added"
# For whatever reason we forgot to merge file c and forgot about it
git merge --no-commit branch_c
git reset c
git commit -m "merge branch c, but forgot file c"
git clean -fxd
# Commands such as git-log fail to show that files were excluded from merges
git log --name-status --all
问题
如何列出从未合并到某个分支的文件? 是否有一种使用git-log
的方法,以便它显示未被合并的文件?
git log --all --stat
,从结果中提取所有文件名,并在一个干净的沙盒中查找它们。也许?注意:这也会包括过去被git rm
删除的文件,所以不完全是你想要的。 - joanis