Git rebase:强制推或拉-推
我们正在公司里讨论在Git rebase:强制推或拉-推,git,github,version-control,Git,Github,Version Control,我们正在公司里讨论在git-rebase之后应该做什么。在rebase之后,您需要将更改推送到远程origin,但是当git不允许时,我们应该如何做呢?事实上,我们正在讨论当分支已经被推上时,我们最常用的两种方法: 1git push-uf原始分支机构 原因:只有源中的分支提交。树将是扁平的 | | | 2 git push -u origin branch ! [rejected] hint: Updates where rejected because the tip of your
git-rebase
之后应该做什么。在rebase
之后,您需要将更改推送到远程origin
,但是当git不允许时,我们应该如何做呢?事实上,我们正在讨论当分支已经被推上时,我们最常用的两种方法:
1<代码>git push-uf原始分支机构
原因:只有源中的分支提交
。树将是扁平的
|
|
|
2
git push -u origin branch
! [rejected]
hint: Updates where rejected because the tip of your current branch is behind
hint: Updates were rejected because the tip of your current branch is behind
hint: "git pull ...") before pushing again.
git pull origin branch
git push -u origin branch
原因:它将创建一个名为“Merged origin/branch to branch Bla”的提交,看起来不必要。它不会翻动树
|\
| |
|/
**force标志看起来很奇怪如果您重新设置分支的基址,则表示您正在重写该分支的历史记录
git push -u origin branch
! [rejected]
hint: Updates where rejected because the tip of your current branch is behind
hint: Updates were rejected because the tip of your current branch is behind
hint: "git pull ...") before pushing again.
git pull origin branch
git push -u origin branch
如果该分支已经被推送,您需要“强制推送”它,因为它的新提示无法通过以前的提示到达(这就是您收到错误消息的原因)
好吧,但看起来很奇怪,不是吗?几乎每次都使用force标志,这可能看起来很奇怪,但是Git希望您在更改分支的历史记录时要小心