我的理解是,在推送本地提交之前正确地整合主干更改,以下是工作流程:
上面的序列假设没有合并冲突(这是我的情况)。
但无论如何,这个过程并没有完全成功:
1)结帐分行..
$git checkout coresql
Already on 'coresql'
2)获取工作..
17:11:40/ysgood $git fetch -a
remote: Counting objects: 24, done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 24 (delta 5), reused 23 (delta 4), pack-reused 0
Unpacking objects: 100% (24/24), done.
From jgithub:/Mycompany/ys
548347b..4975c4f coresql -> origin/coresql
3)rebase 不 做正确的事情:主干中有没有反映的变化(?)
17:11:51/ysgood $git rebase origin coresql
Already on 'coresql'
Current branch coresql is up to date.
4)因此,自然 push 失败,因为主干更改没有正确地集成到本地
17:12:23/ysgood $git push origin coresql
To git@jgithub:/ThirdEyeCSS/yardstick-spark
! [rejected] coresql -> coresql (non-fast-forward)
error: failed to push some refs to 'git@jgithub:/Mycompany/ys'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
那么为什么git fetch -a / git rebase无法正常工作?
答案 0 :(得分:2)
git rebase
期望分支,而非远程:
git rebase origin/coresql
如果使用双参数版本的rebase,它指定从哪个分支到哪个分支到rebase,基本上是git checkout SECOND && git rebase FIRST
。
您也可以使用git pull --rebase origin coresql
代替fetch
+ rebase
。