Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
文件的Git历史记录,该文件由Git merge-s子树修改_Git_Git Merge_Git History - Fatal编程技术网

文件的Git历史记录,该文件由Git merge-s子树修改

文件的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 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: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中的
    显示历史记录
    会显示日志条目
由于我的IDE实现了这一点,我猜git log中有一个标志组合来向我显示正确的历史记录,但是我尝试了很多组合,但都没有弄清楚。是的,我确实读过手册页

此外,如果一个不同的程序可以阻止我进入这种情况,我想知道。。。Doe回想起来,也许旧的主分支是不必要的,但最初有一个分支来解决冲突似乎是个好主意


谢谢

如果合并提交没有在目标文件上引入额外的修改,
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
    -查找更难的副本
  • 使用
    -M
    设置较低的检测阈值?(默认值为50%,例如
    -M40%
  • 如果两次回购之间的crlf行尾不同:
    ——在下线忽略cr
  • 设置忽略空白更改的选项:
    --忽略下线处的空白
    -b
关于git中的“重命名”:您当然知道git不会在其历史记录中跟踪重命名,它只跟踪您告诉它要存储的内容。

当它在
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
    -查找更难的副本
  • 使用
    -M
    ?(默认值为50%,
    -M40%
    )设置较低的检测阈值
  • 如果两次回购之间的crlf行尾不同:
    ——在下线忽略cr
  • 设置忽略空白更改的选项:
    --忽略下线处的空白
    -b
关于git中的“重命名”:您当然知道git不会在其历史记录中跟踪重命名,它只跟踪您告诉它要存储的内容。
当它在中显示“重命名”时