当我在 master 分支中执行
git pull
操作时,git 显示以下消息:
There is no tracking information for the current branch.
Please specify which branch you want to merge to.
See git-pull(1) for details.
git pull <remote> <branch>
If you want to set up the tracing information for this branch, you can do it with:
git branch --set-upstream-to=origin/<branch> master
当我在 master 分支中执行
git push
时,git 显示此消息:
fatal: The current master branch does not have an upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
所以我做
git push --set-upstream origin master
,git 显示此消息:
To <my-server-name>
! [rejected] master -> master (non-fast-forward)
error: failed to push some references to '<my-server-name>'.
help: Updates were rejected because the tip of your current branch is
help: behind its remote counterpart. Integrate remote changes (i.e.
help: 'git pull ...') before pushing again.
help: See 'Note about fast-forwards' in 'git push --help' for details.
请帮助我!
您首先需要通过运行以下命令来确保您的本地分支引用上游分支:
git branch --set-upstream-to=origin/<branch> master
之后,您需要执行
git pull
从上游分支获取丢失的更改。
完成更改后,您将能够执行
git push
,但您也可能必须执行 manual merge
才能解决因您所做的更改而产生的任何冲突那些存在于上游分支中的。