1

Met with errors in the 2nd git push, I just want to add some new changes to the same Pull Request, any thoughts how to resolve this issue? Thanks.

Git operations

git checkout -b newFooBranch
git add <name of file changed>
git commit -m 'add some initial changes'
git push origin newFooBranch

// make some changes
git add <name of same file changed>
git commit -m 'add some new changes on the same file'
// met with error when executing below command
git push origin newFooBranch

Error Message,

To [email protected]:foo/goo.git
 ! [rejected]        newFooBranch -> newFooBranch (non-fast-forward)

error: failed to push some refs to '[email protected]:foo/goo.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.

Edit 1,

git pull
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> newFooBranch

regards, Lin

2
  • 1
    If no one else has committed to that branch and pushed, then you've moved your local HEAD pointer, possibly with a git checkout command. Just look at github and see which commits are different than your local commits. Commented Jul 31, 2016 at 5:06
  • @AndyRay, thanks and vote up. What do you mean "Just look at github and see which commits are different than your local commits"? Is there a section on github.com to see? Commented Jul 31, 2016 at 5:08

1 Answer 1

1

Do either:

git pull

or:

git remote update
git rebase origin/newFooBranch

before pushing your change.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks Nishant, vote up and met with error when executing git pull, post on edit 1 section of my original post, if you have any thoughts, it will be great.
Try git pull origin newFooBranch.
You can also do git branch --set-upstream-to=origin/newFooBranch newFooBranch as the error message says. Essentially git doesn't know which branch to pull from (as the new branch was created without any upstream) so it asks you to be more specific.
And once you set up an upstream with --set-upstream-to you won't have to specify the branchname in pull and just git pull will be sufficient.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.