Reputation: 10665
I have this branch:
local:
bugfix/VMS-172-back-arrow-on-activity-bar
remote:
origin/bugfix/VMS-172-back-arrow-on-activity-bar
So I added my changes locally then pushed it.
Then I made few changes locally again and I pushed it ( I used git commit --amend
when committing). But this time git asked me to pull before pushing. Why?
My git log:
commit f38a4d8828a2fadec3c62c08cc1c90ea66a719bd
Merge: 172968f 642178d
Author: degensharew <[email protected]>
Date: Thu Oct 15 09:45:59 2015 +0300
Merge branch 'bugfix/VMS-172-back-arrow-on-activity-bar'
of myrepository into bugfix/VMS-172-back-arrow-on-activity-bar
Conflicts:
vms-mobile/app/src/main/java/AbstractActivity.java
commit 172968f6dcf533e43749986eba95a008c585bbb1
Author: degensharew <[email protected]>
Date: Wed Oct 14 17:21:01 2015 +0300
Fixed bug VMS-172.
Avoided rounded corner style from search view.
Style back arrow and title of action bar view.
Disabled 'back action' from activity title.
commit 642178d27bccbe9ea48c7d8ae123f1c8c01f921f
Author: degensharew <[email protected]>
Date: Wed Oct 14 17:21:01 2015 +0300
Fixed bug VMS-172.
Avoided rounded corner style from search view.
Style back arrow and title of action bar view.
Disabled 'back action' from activity title.
NB: I am the only one working on this branch.
Upvotes: 1
Views: 73
Reputation: 521178
I used git commit --amend when committing).But this time git asked me to pull before pushing. Why?
When you used git commit --amend
, you rewrote the history of the HEAD
commit in your local branch. This means that at this point your local and remote branches were diverging from each other.
Before commit amend:
remote: A <- B <- C
local: A <- B <- C
After commit amend:
remote: A <- B <- C
local: A <- B <- C' (the apostrophe indicates a new commit)
You cannot fast forward the remote branch since your local branch has diverged from the remote. Effectively, your latest commit sits on top of a different base than the remote, and Git is refusing to automatically apply this commit. The two solutions here would be to merge your local branch into the remote, or to rebase your local branch on the remote, and then push it in.
As to why you were forced to pull again, this could be for a number of reasons. For example, if you did another commit amend, this could explain it. A coworker committing to the same branch could also explain it, but not in your case since you stated you are the only one working this branch.
Upvotes: 2