This happens because your local copy of the branch you want to merge is out of date. I've got my branch, called MyBranch
and I want to merge it into ProjectMaster
.
_>git status
On branch MyBranch-Issue2
Your branch is up-to-date with 'origin/MyBranch-Issue2'.
nothing to commit, working tree clean
_>git merge ProjectMaster
Already up-to-date.
But I know that there are changes that need to be merged!
Here's the thing, when I type git merge ProjectMaster
, git looks at my local copy of this branch, which might not be current. To see if this is the case, I first tell Git to check and see if my branches are out of date and fetch any changes if so using, uh, fetch
. Then I hop into the branch I want to merge to see what's happening there...
_>git fetch origin
_>git checkout ProjectMaster
Switched to branch ProjectMaster
**Your branch is behind 'origin/ProjectMaster' by 85 commits, and can be fast-forwarded.**
(use "git pull" to update your local branch)
Ah-ha! My local copy is stale by 85 commits, that explains everything! Now, I Pull
down the changes I'm missing, then hop over to MyBranch
and try the merge again.
_>git pull
Updating 669f825..5b49912
Fast-forward
_>git checkout MyBranch-Issue2
Switched to branch MyBranch-Issue2
Your branch is up-to-date with 'origin/MyBranch-Issue2'.
_>git merge ProjectMaster
Auto-merging Runbooks/File1.ps1
CONFLICT (content): Merge conflict in Runbooks/Runbooks/File1.ps1
Automatic merge failed; fix conflicts and then commit the result.
And now I have another issue to fix...