git 合并原点 - 始终默认为跟踪分支?
git merge origin - always defaults to tracking branch?
假设我有一个脚本可以执行以下操作:
git fetch origin
git branch | while read b; do
git checkout $b
git merge origin
done
我的问题是 - git 是否总是知道如何使用 git merge origin
命令,假设所有分支都被远程跟踪?
... will git always know what to do with the git merge origin
command ...
Git 总是会做 某事。不过,可能不是您想要的!你可能想要:
git checkout $b
git merge $b@{upstream}
这不是会发生什么。
当 Git 将 master
或 origin/develop
或 MERGE_HEAD
之类的字符串解析为提交哈希 ID 时,它遵循 the gitrevisions documentation 中描述的规则.特别地,使用了六个步骤。第一个检查 .git
目录中的文件。第三步检查标签名称,第四步检查分支名称。
请按照上面的 link 并检查 SPECIFYING REVISIONS 部分下列出的六个步骤中的每一个,并思考当 Git 尝试时会发生什么origin
每一步。例如,在第 1 步,Git 将检查名为 .git/origin
的文件,该文件(大概)不存在。请注意,当第 6 步应用于文字字符串 origin
时,会检查您的 refs/remotes/origin/HEAD
。现在 运行:
$ git rev-parse refs/remotes/origin/HEAD
查看您获得的哈希 ID。这告诉你 git merge origin
将如何表现。
(要查看如何更改与 refs/remotes/origin/HEAD
关联的哈希 ID,请参阅 the git remote
documentation,特别是 set-head
子命令。但请改用 @{upstream}
表示法.)
假设我有一个脚本可以执行以下操作:
git fetch origin
git branch | while read b; do
git checkout $b
git merge origin
done
我的问题是 - git 是否总是知道如何使用 git merge origin
命令,假设所有分支都被远程跟踪?
... will git always know what to do with the
git merge origin
command ...
Git 总是会做 某事。不过,可能不是您想要的!你可能想要:
git checkout $b
git merge $b@{upstream}
这不是会发生什么。
当 Git 将 master
或 origin/develop
或 MERGE_HEAD
之类的字符串解析为提交哈希 ID 时,它遵循 the gitrevisions documentation 中描述的规则.特别地,使用了六个步骤。第一个检查 .git
目录中的文件。第三步检查标签名称,第四步检查分支名称。
请按照上面的 link 并检查 SPECIFYING REVISIONS 部分下列出的六个步骤中的每一个,并思考当 Git 尝试时会发生什么origin
每一步。例如,在第 1 步,Git 将检查名为 .git/origin
的文件,该文件(大概)不存在。请注意,当第 6 步应用于文字字符串 origin
时,会检查您的 refs/remotes/origin/HEAD
。现在 运行:
$ git rev-parse refs/remotes/origin/HEAD
查看您获得的哈希 ID。这告诉你 git merge origin
将如何表现。
(要查看如何更改与 refs/remotes/origin/HEAD
关联的哈希 ID,请参阅 the git remote
documentation,特别是 set-head
子命令。但请改用 @{upstream}
表示法.)