1

I am trying to push the committed files into git bitbucket. My remote name is pb and branch name is Pr_1. So I have done git push pb. But it is giving me error saying it is rejected.

Commands used:

git push pb Username for 'https://<bitbucket name>' : [email protected] Password for 'https://<bitbucket name>' : *** 

Error result :

To https:<bitbucket clone link> ! [rejected] Pr_1 -> Pr_1 (non-fast-forward) error: Error in sending some references after'https://<bitbucket clone link>' Note: Updates have been rejected because the top of your current Note: Branches has fallen behind its external counterpart. Run Note: The external changes together (e.g. ' git pull ... ') before you "push " Note: Run again. Note: See also the section ' Note about fast-forwards ' in ' git push--help ' Note: For more details. 

Also, tried as per hints in the error result and did push again. enter image description here Why am I unable to push the changes which I have committed? How can my push be reflected in bit bucket?

enter image description here

4
  • 4
    If you read carefully the hints git tries to give you (not in the clearest way ever, granted) you'll see that the remote version of your branch has some commits which aren't known to your local version of it. You should first pull changes (and resolve the potential conflicts) then push yours. Commented Nov 8, 2018 at 11:25
  • as added above, I have done git pull nut everything is already up-to-date Commented Nov 8, 2018 at 11:35
  • Possible duplicate of How to resolve git error: "Updates were rejected because the tip of your current branch is behind" Commented Nov 8, 2018 at 11:36
  • Nope.. Not at all.. It is not the same Commented Nov 8, 2018 at 11:59

1 Answer 1

1

Priya, the answer is actually similar to what is mentioned in the question tagged by @kowsky. How ever let me try to explain what is happening.

What git is trying to tell you is the Pr_1 branch has changed on the server and your common commit is no longer the HEAD of remote repository. This must be because of one of the following reasons, and solution is different based on the situation:
1. You must be amending the last commit before pushing it
Solution: In this case you will have to force push your changes git push pb Pr_1 --force(before that be absolutely sure that there are no other commits pushed to remote)

2. Someone else must have pushed changes on Pr_1 while you were making changes
Solution: Take and update git pull pb Pr_1 if there are conflicts resolve them and then push git push pb Pr_1

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

1 Comment

Your solution worked as a miracle for me. What you explained is true. Actually, it was very useful. Thank you so much :) I tried using "rebase" as mentioned in the other question. But it did not work. so I was stating it is different. I now get it clearly. But I did not amend the last commit before pushing. I committed the new changes and tried to push without editing any further. But the possible error should be that there are more commits pushed to remote.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.