我是一个深藏在git中的文件。
如何进入其中:
我不是一个git专家,请在我缺少任何细节时向我询问澄清。几天前,我运行了以下命令将我的更改推送到远程分支。
% git checkout master
% git pull
% git checkout redactor_changes <-- this is the branch that I made my changes
% git commit -m "changes" # I added my changes previously
% git rebase master
% git push origin redactor_changes # pushed changes to remote branch
并不是每个人都有向主分支合并更改的写入权限。在远程仓库拥有写入权限的人告诉我存在冲突,要进行一次变基并重新提交。所以今天我按照以下确切顺序运行了这些命令。
vagrant@vagrant-ubuntu-trusty-64:~/oblog$ git add oblog/static/css/styles-custom.css
vagrant@vagrant-ubuntu-trusty-64:~/oblog$ git add oblog/static/js/redactor.upload_image.js
vagrant@vagrant-ubuntu-trusty-64:~/oblog$ git add oblog/static/images/loading.gif
vagrant@vagrant-ubuntu-trusty-64:~/oblog$ git commit -m "Throw a toast when user upload an non-image file with image extension"
vagrant@vagrant-ubuntu-trusty-64:~/oblog$ git branch
vagrant@vagrant-ubuntu-trusty-64:~/oblog$ git checkout master
vagrant@vagrant-ubuntu-trusty-64:~/oblog$ git pull
vagrant@vagrant-ubuntu-trusty-64:~/oblog$ git checkout redactor_changes
vagrant@vagrant-ubuntu-trusty-64:~/oblog$ git rebase master
vagrant@vagrant-ubuntu-trusty-64:~/oblog$ git merge master
vagrant@vagrant-ubuntu-trusty-64:~/oblog$ git branch
vagrant@vagrant-ubuntu-trusty-64:~/oblog$ git push origin redactor_changes
看起来这组命令把我卷入了一个无法逃脱的漩涡。
症状:
上述代码的最后一行会抛出以下错误。
! [rejected] redactor_changes -> redactor_changes (non-fast-forward)
error: failed to push some refs to 'https://git.<domain>.com/web/oblog.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.
所以我遵循了来自 SO 社区的建议:
但问题仍然存在。
LABLE:
当我将我的分支本地与主分支进行 rebase 时,会出现一些冲突,然后我手动解决并继续执行 rebase --continue。Rebase 成功后,我再次将我的分支推送到 origin,但它显示相同的错误,! [rejected]。
像 git 和 SO 建议的那样,我拉取远程分支上的更改到我的本地分支(redactor_changes),然后执行:
git rebase master
这让我回到了标签上。这个问题一直存在。
请注意,如果我不将它与主分支进行rebase,我的push命令可以正常工作,但是当远程git的所有者尝试将我的分支(redactor_changes)合并到主分支时,仍然会看到冲突。
git rebase master
之后立即执行了git merge master
。你为什么这样做? - Tim Biegeleisen