我从github克隆了一个朋友的存储库并对其进行处理。该存储库具有master和Dev分支。我将更改推送到Dev分支上,
git push -u origin Dev
但不断出错:
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.
答案 0 :(得分:1)
基本上,由于创建了本地分支,因此对Dev分支进行了更多更改,因此您会收到当前分支位于远程后面的错误消息。
您只需要下拉更改,然后尝试再次推送即可。
git pull --rebase
=> Removes your changes, updates you branch to the latest and the applies all your changes.
git push origin Dev
=> Pushes your changes to the remote branch
如果您不想重新设置基础,可以尝试使用git pull,它会降低所有更改以更新本地分支,并在处理过程中将创建合并提交。
我个人主要遵循git pull --rebase
和git push
的顺序。