0

I have branch named X which I want to push to a remote master branch.

But when I execute:

git fetch remote_name
git checkout -B branchX remote_name/master
...
Add a commit
...
git push remote_name master

I get an error saying:

Updates were rejected because a pushed branch tip is behind its remote
counterpart. Check out this branch and integrate the remote changes...

If i check my branchX unique commit value, then I can see that the checkout was correct and there have been added a new commit, so for sure i am a head of remote_name master. And the remote master has NOT received any new commits in the meantime.

I normally use this procedure other places only difference here is that the branch names are not identical. What am i doing wrong?

2
  • What does 'git status' say? Commented Oct 15, 2013 at 15:39
  • If your local change is in branchX, why did you push branch master? Commented Oct 15, 2013 at 15:44

2 Answers 2

3

You are trying to push your local repo's master to your remote's master. Your push command effectively expands to this:

git push remote_name refs/heads/master:refs/heads/remote_name/master

Obviously, that's not what you're trying to do. You need to explicitly specify which branches go where:

git push remote_name branchX:master
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. Makes sense. Had trouble understanding the docs :).
1

Try:

git push remote_name branchX:master

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.