Priya
Priya

Reputation: 339

git unable to push after commiting the changes

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

Upvotes: 1

Views: 1355

Answers (1)

Mudassir Razvi
Mudassir Razvi

Reputation: 1833

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

Upvotes: 1

Related Questions