当我尝试使用VSCode将最新代码推送到Github上的master分支时,出现一条弹出错误消息,建议以下内容:
无法将引用推送到远程。首先尝试运行“拉”以集成您的更改。
因此,我尝试了“拉”,但出现了一个弹出窗口建议我:
该分支没有跟踪信息。
这是Push的Git日志:
> git push origin master
To https://github.com/WebDevelopWolf/Date-A-Dog.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/WebDevelopWolf/Date-A-Dog.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.
和“拉”的Git日志:
> git pull --tags
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> master
我可以看到它正在询问合并-但是,我只有一个分支,这就是原始的master分支。那里有很多代码,但是最后提交的是README.md文件,我是从GitHub本身完成的,所以我不知道这是否有所不同?
您的本地分支位于您关心的远程分支的后面,因此您需要拉出这些更改(--rebase
在这种情况下,最好使用这些更改)。
但是,git pull
默认情况下是从跟踪分支中提取。有问题的分支没有跟踪任何内容。
因此,按照错误消息的说明进行操作git branch --set-upstream...
,然后使用git pull
,然后尝试git push
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句