这个恼人的东西时常出现。
1. Fix only remote repository branch which is behind commit
- ahead === Master branch
- behind === Develop branch
Solution:
-
Pull from the remote Develop branch. Conflict might occur. if so, fix the conflict and commit the changes.
git pull origin dev -
Merge the local Develop branch with the remote Develop branch
git merge origin dev -
Push the merged branch to the remote Develop branch
git push origin dev
2. Local Master branch is behind the remote Master branch
This means every locally created branch is behind.
Before preceding, you have to commit or stash all the changes you made on the branch behind commits.
Solution:
-
Checkout your local Master branch
git checkout master -
Pull from remote Master branch
git pull origin master
Now your local Master is in sync with the remote branch. As a result of the above command, other local branches branched from the previous local Master branch are not in sync. To fix that:
-
Checkout the branch that is behind your local Master branch
git checkout BranchNameBehindCommit -
Merge with the local Master branch
git merge master // Now your branch is in sync with the local Master branch
If this branch is on the remote repository, you have to push your changes.
git push origin branchBehindCommit