Lin Ma Lin Ma - 1 year ago 153
Git Question

strange git push error

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,

! [rejected] newFooBranch -> newFooBranch (non-fast-forward)

error: failed to push some refs to ''
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


Answer Source

Do either:

git pull


git remote update
git rebase origin/newFooBranch

before pushing your change.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download