fsociety
fsociety

Reputation: 1027

Unable to push to remote branch

I do the below in my master branch:

git fetch --all

git reset --hard origin/master

Then i create a new branch and switch to the new branch using:

git checkout -b new_branch

I edit and add some files in the new_branch. Then i finally commit.However, when i push the changes, i get the below message:

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.

I have already seen these threads,but still the error persists:

Cannot push to GitHub - keeps saying need merge

Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g

What else am i missing, i fail to understand? Just to add, i have also deleted my_branch, again updated the master with the latest remote, recreated the new branch, still i encounter the same error, please suggest where i might be going wrong.

Upvotes: 1

Views: 2150

Answers (2)

Donal
Donal

Reputation: 32713

You can force your push with the -f switch. The -f switch forces the push, and will overwrite the branch on the server. Use with caution when working in a team.

git push -f origin new_branch

Upvotes: 1

Thomas5631
Thomas5631

Reputation: 244

Try running:

git pull

If this branch is new, then you can set the upstream with:

git push -u origin new_branch

Upvotes: 0

Related Questions