该手册git rebase页显示:
如果
<upstream>未指定,将使用在branch.<name>.remote和branch.<name>.merge选项中配置的上游。[....]
然后将先前保存到临时区域中的提交依次重新应用于当前分支。请注意,任何
HEAD引入与提交内容相同的文本更改的提交HEAD..<upstream>都将被忽略(即,将跳过上游已接受且带有不同提交消息或时间戳的补丁程序)。
确实,当我致电git rebase master并进行master与本地分支机构历史记录相同的文本更改的提交时,它将被忽略。但是,我发现,当我调用时git rebase未指定<upstream>(默认为master)时,的输出git rebase似乎显示了相同的提交未被忽略。
这是一个示例来证明这一点。这是git的历史记录:
A---B master
\
B' topic
Run Code Online (Sandbox Code Playgroud)
B并B'进行相同的文本更改,但提交信息有所不同。topic设置为跟踪master。
首先,我在补货的topic同时进行了调整<upstream>:
$ git checkout topic
$ git rebase master
First, rewinding head to replay your work on top of it...
Run Code Online (Sandbox Code Playgroud)
没有预期的事情发生,因为B和B'是完全相同的。
但是,如果我省略<upstream>:
$ git checkout topic
$ git rebase
First, rewinding head to replay your work on top of it...
Applying: Branch: topic
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
No changes -- Patch already applied.
Run Code Online (Sandbox Code Playgroud)
好像git B'在第二个输出中没有跳过。有人可以解释这个差异吗?
(我正在使用git版本1.9.4)
现在情况已不再如此(使用最新的 Git 2.38.0 进行测试)。这是一个简单的、完全可重现的测试用例:
git init 26878037
cd 26878037
echo a > file
git add file
git commit -m 'initial commit'
git branch topic --track master
echo b >> file
git add file
git commit -m 'commit on master'
git checkout topic
echo b >> file
git add file
git commit -m 'commit on topic'
git rebase # defaults to upstream of topic, which is master
git log
Run Code Online (Sandbox Code Playgroud)
命令的输出rebase:
warning: skipped previously applied commit d07369f
hint: use --reapply-cherry-picks to include skipped commits
hint: Disable this message with "git config advice.skippedCherryPicks false"
Successfully rebased and updated refs/heads/topic.
Run Code Online (Sandbox Code Playgroud)
日志输出:
a8002a0 (HEAD -> topic, master) commit on master
7443187 initial commit
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
133 次 |
| 最近记录: |