【发布时间】:2016-10-20 12:55:01
【问题描述】:
我深埋在一个 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
不是每个人都有写入权限将更改合并到主分支。对远程仓库有写权限的人告诉我有冲突,做一个 rebase 并再次提交。所以今天我按照确切的顺序运行了以下命令。
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.
所以我听从了同胞的建议
但问题仍然存在。
标签:
当我使用 master(本地)rebase 我的分支时,它会引发一些冲突,然后我手动修复并执行 rebase --continue。变基成功。然后我再次将我的分支推到原点,它显示了同样的错误,! [拒绝]。
按照 git 和 SO 的建议,我继续将远程分支上的更改拉到本地分支 (redactor_changes)。然后执行
git rebase master
这让我回到了LABEL。这会一直持续下去。
请注意,如果我不使用 master 重新设置它的基础,我的 push 命令可以工作,但是远程 git 的所有者在尝试将我的分支 (redactor_changes) 合并到 master 时仍然会看到冲突。
【问题讨论】:
-
我看到的一个问题是您在执行
git rebase master之后在之后立即执行了git merge master。你为什么这样做? -
我的意图是与 master 合并更改以使我的分支保持最新,然后运行 rebase 以将分支定位到 master。您认为这可能导致所有这些问题?
标签: git git-merge rebase git-push