Usually to resolve this I do git stash. But this time I want to make sure I push my change. Git stash just hides my changes, right? So is there a way to resolve this error message and make sure I push my code?
git - I need to push my latest changes and get error that my branch tip is behind remote counterpart
1 Answer
You need to fetch recent changes from the remote server and rebase your current branch against them:
git pull --rebase
After that (if you are lucky and no one has pushed more changes) you can push again:
git push
11 Comments
Genadinik
Thanks. I just tried it and the pull seemed to have worked ok. But the push gave this error: Updates were rejected because a pushed branch tip is behind its remote
Sergey K.
This means you have more than one branch. Please, post the complete output of
git push.Genadinik
Actually I did git push origin master. Should I have just done the git push?
Genadinik
This is the error: ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'my_url' hint: Updates were rejected because a pushed branch tip is behind its remote hint: counterpart. Check out this branch and merge the remote changes hint: (e.g. 'git pull') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Sergey K.
It does not matter. Do you see the line like
master -> origin/master? |