每当我尝试将更改推送到我自己的git repo时,我都会收到错误:
error: failed to push some refs to '--myrepo-here--'
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.
Completed with errors, see above
这是我的工作流程。
我们有一个git repo。 [主人]
团队中的每个人都分配了主要的回购。
无论如何,没有人可以推送我的回购。但我经常收到这个错误。它说我从遥远的回购中落后了。
答案 0 :(得分:2)
尝试使用此方法对已更改的母版重新定位:
# Add the original remote, e.g. "upstream":
git remote add upstream https://github.com/whoever/whatever.git
# Fetch all the branches of that remote into remote-tracking branches,
# such as upstream/master:
git fetch upstream
# Make sure that you're on your intended branch, e.g. master:
git checkout master
# Rewrite your branch so that any commits of yours that
# aren't already in upstream/master are replayed on top of that branch:
git rebase upstream/master
# resolve any merge conflicts
# push the end result
git push origin master
答案 1 :(得分:0)
似乎是执行pull --rebase
而不仅仅是git pull MainRepo master
的结果
你应该阅读Git rebase
这是一个Git Cheatsheet。
这些步骤足以满足您尝试完成的工作流程:
当您准备好拉动并推动您的更改时
git pull origin master
解决任何冲突后
git commit -m "commit message" files
git push (or git push -u origin/your-branch)