简体   繁体   中英

Error when pushing to remote master branch on GitHub from VSCode

When I attempt to push my latest code to the master branch on Github using VSCode I get a pop-up error message advising the following:

Can't push refs to remote. Try running 'Pull' first to integrate your changes.

So I try a Pull, but I get a pop-up window advising me:

There is no tracking information for that branch.

Here's the Git log for the Push:

> 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.

And the Git Log for the 'Pull':

> 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

I can see it's asking about merging - however I only have the one branch and that's the original master branch. There is a fair bit of code in there, but the last thing that was committed was a README.md file and I did that from GitHub itself, so I don't know if that makes a difference at all?

Your local branch is behind the remote branch you care about, so you need to pull those changes (preferably with --rebase in this case).

However, git pull by default pulls from a tracked branch. The branch in question is not tracking anything.

So, follow the error message's instructions and use git branch --set-upstream... , then git pull , then try git push .

Do below sequence

  1. Git pull origin master
  2. resolve any merge conflicts if any
  3. git add .
  4. git commit -m "....."
  5. git push

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM