1

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?

1
  • 1
    git stash doesn't touch your committed changes so it cannot help here. Commented Mar 26, 2013 at 15:43

1 Answer 1

1

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

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

11 Comments

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
This means you have more than one branch. Please, post the complete output of git push.
Actually I did git push origin master. Should I have just done the git push?
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.
It does not matter. Do you see the line like master -> origin/master?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.