我在使用git时遇到了问题。我想要将分支hotfix
在本地和远程都基于master
进行rebase,这是我的操作:
git checkout hotfix
git pull hotfix #just getting someone changes
git fetch origin master
git rebase origin/master
经过长时间解决冲突和重建项目,我已经使其正常工作,所以我必须将更改上传到远程分支。
git push origin hotfix
这是Git的想法:
$ git push origin login2
To https://name@bitbucket.org/***/***.git
! [rejected] hotfix -> hotfix (non-fast-forward)
error: failed to push some refs to 'https://name@bitbucket.org/***/***.git'
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 pull --rebase
但这样会和之前的rebase一样出现冲突,这是不应该的。
我知道我总是可以执行:
git push -f
但是我希望避免强制推送,因为我和另一个人一起工作。我想知道我做错了什么。我以为那就是方法。
附注:我运行了gitk
,看起来没有提到远程origin/hotfix
,只有本地的hotfix
出现。
谢谢!
编辑:我猜当我重新基于分支时,最后一个提交更改以应用rebase更改,这就是为什么它有另一个sha1提交ID的原因。我进行了覆盖本地文件的拉取。
git pull --strategy=ours origin hotfix