git log -M --follow --full-history new/directory/file
甚至失败时,如何让 git log 向我显示文件的整个历史记录。
但首先是关于未显示更改的一些上下文......
我们在另一个仓库中导入了一个 git 仓库,我们是这样进行的:
git clone git@domain.com:namespace/NewRepository
cd NewRepository
git remote add oldRepository git@domain.com:oldNamespace/oldRepository.git
git fetch oldRepository
git checkout -b old-master oldRepository/master
mkdir -p new/directory/
git mv -k * new/directory/
find . -name ".*" -d 1 -exec git mv -k {} new/directory/ \;
git commit -m "Move oldRepository to its new location"
git push --set-upstream origin old-master
git checkout master
git pull
git merge old-master --allow-unrelated-histories
git push
到目前为止一切顺利,在此之后 agit log --follow new/directory/file
会给我文件的完整变更日志。
大约一周后,需要将旧存储库的一些新更改“拉入”到新存储库中。我们是这样进行的:
git fetch --all
git checkout old-master;
git merge origin/old-master; # I got no conflict (No change actually)
git merge origin/master; # I got no conflict (As expected)
git merge -s subtree -X patience oldRepository/master;
# I am not sure "-X patience" is a thing but that's what we ran.
# But the "-s subtree" is the important part I believe, we got no conflict and all expected changes were found in their new location (Even newly created files)
git push --set-upstream origin old-master
然后我创建了一个 PR,然后最终使用create a merge commit选项将其合并。
现在,如果我执行git log --follow new/directory/file
最新的提交,我看到的是:Move old repository to its new location
,但是我没有从旧存储库中获得任何更新的条目,这些条目是在原始导入之后完成的。尽管文件中存在更改。
然而 :
- A
git blame new/directory/file
确实在修改后的行旁边向我显示了正确的信息 - A
git log
(没有指定文件)确实向我展示了提交 - 我的 IDE 中的 A
show history
确实向我显示了日志条目。
由于我的 IDE 做到了,我猜测 git log 有一个标志组合来向我显示正确的历史记录,但我尝试了很多组合但无法弄清楚。是的,我确实阅读了手册页...
此外,如果不同的程序可以阻止我进入这种情况,我想知道...... Doe 回想起来也许老主分支是不必要的,但最初似乎有一个分支来解决冲突是个好主意.
谢谢!