文件的Git历史记录,该文件由Git merge-s子树修改
当git log-M--follow--full history new/directory/file失败时,我如何让git log显示文件的整个历史记录 但首先是一些没有显示的变化的背景 我们在另一个git存储库中导入了一个git存储库,我们是这样进行的:文件的Git历史记录,该文件由Git merge-s子树修改,git,git-merge,git-history,Git,Git Merge,Git History,当git log-M--follow--full history new/directory/file失败时,我如何让git log显示文件的整个历史记录 但首先是一些没有显示的变化的背景 我们在另一个git存储库中导入了一个git存储库,我们是这样进行的: git clone git@domain.com:namespace/NewRepository cd NewRepository git remote add oldRepository git@domain.com:oldNamespa
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
到目前为止还不错,在此之后,git日志——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,并最终使用CREATEAMERGECOMMIT选项将其合并
现在,如果我做了git log--遵循new/directory/file
我看到的最新提交是:将旧存储库移动到它的新位置
,但是我没有从旧存储库中获得任何在原始导入后完成的更新条目。尽管文件中存在更改
然而:
- 一个
会在修改的行旁边显示正确的信息git/new/directory/file
- 一个
(没有指定文件)会显示提交git日志
- IDE中的
会显示日志条目显示历史记录
谢谢 如果合并提交没有在目标文件上引入额外的修改,
git log new/directory/file
将不会显示合并提交本身(这可能有点令人不安),并且取决于它选择显示提交的顺序,来自旧主机
分支的提交可能位于日志
列表的更下方
尝试添加--graph
选项:
git log --graph --follow new/directory/file
# or
git log --graph --oneline --follow new/directory/file
并查看是否对修改该文件的提交有更清晰的了解
您也可以尝试使用--日期顺序
,--作者日期顺序
和--地形顺序
标志
[编辑]当我第一次阅读你的问题时,我不知怎么地认为
新/目录
也被创建并推到了旧存储库
。因此我推断,oldRepository
中的修改被应用于new/directory/file
,因此我发现git不会列出new/directory/file
的历史记录,这让我感到惊讶
我现在了解到,在oldRepository
中,文件的路径是/file
,将新提交作为git日志的一部分——follow new/directory/file
依赖于git启发式方法来查找重命名
关于git日志中的选项,您是否尝试过:
- 使用
和-C
-查找更难的副本
- 使用
设置较低的检测阈值?(默认值为50%,例如-M
)-M40%
- 如果两次回购之间的crlf行尾不同:
——在下线忽略cr
- 设置忽略空白更改的选项:
或--忽略下线处的空白
-b
当它在
git日志
或git状态
或。。。实际上,它试图通过查看全局内容之间的差异来猜测哪些文件可能被重命名。例如,<代码> -M50%选项,表示如果代码50%的文件是相同的,则认为<>代码>文件b>代码>可能被“<代码>文件\ < /代码>移动。 < p>如果合并提交没有对目标文件进行额外修改,<代码> Git日志新/目录/文件< /代码>将不会显示合并提交本身。(这可能有点令人不安),并且取决于它选择显示提交的顺序,来自旧主机
分支的提交可能在日志
列表的下一步
尝试添加--graph
选项:
git log --graph --follow new/directory/file
# or
git log --graph --oneline --follow new/directory/file
并查看是否对修改该文件的提交有更清晰的了解
您也可以尝试使用--日期顺序
,--作者日期顺序
和--地形顺序
标志
[编辑]当我第一次读到你的问题时,我不知怎的认为
new/directory
也被创建并推到了oldRepository
。因此我推断oldRepository
中的修改被应用到了new/directory/file
,我发现git竟然没有列出new/directory/file>的历史记录
我现在了解到,在oldRepository
中,文件的路径是/file
,将新提交作为git日志的一部分——follow new/directory/file
依赖于git启发式方法来查找重命名
关于git日志中的选项,您是否尝试过:
- 使用
和-C
-查找更难的副本
- 使用
?(默认值为50%,-M
)设置较低的检测阈值-M40%
- 如果两次回购之间的crlf行尾不同:
——在下线忽略cr
- 设置忽略空白更改的选项:
或--忽略下线处的空白
-b
当它在中显示“重命名”时