Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git merge does not merge

Tags:

I have a master and "PersonalSite" branch for a codebase I'm working on. I have been repeatedly trying to merge the master into the PersonalSite branch to no avail.

This time, I thought I had everything straightened out, so I did:

git checkout master git pull git checkout PersonalSite git pull git merge master 

It looked like everything was working, and it listed the set of files I would have expected, but there was a conflict. The conflict was correct and was as expected, so I fixed it, did "git add", "git commit", then "git push". But now, when I look at my git log, it just shows a commit with no code changes but a single conflict.

Now, when I run "git merge master" from the "PersonalSite" branch it says "Already up-to-date." but this clearly is not the case, as none of the changes I tried to merge actually merged. What exactly do I do to get master to actually merge at this point?

like image 434
LAW Avatar asked Oct 12 '11 20:10

LAW


People also ask

Why git merge not working already up to date?

The message “Already up-to-date” means that all the changes from the branch you're trying to merge have already been merged to the branch you're currently on. More specifically it means that the branch you're trying to merge is a parent of your current branch.

How do I commit changes after merging?

Go to "Team Explorer - Home" => Settings => (Git) Global Settings and toggle "Commit changes after merge by default." checkbox and Update.

Do I need to commit before merge?

Conclusion. The “commit your changes or stash them before you can merge” error is raised when you try to pull code from a remote repository that conflicts with a local change you have made to a repository.


2 Answers

By fixing the conflict and committing the merge conflict you've already completed the merge. Git adds merge commits when necessary, it's normal but they don't record anything except that the merge took place and what files were merged if there was a conflict. If you look more closely at your log you'll see there are in fact commits from master.

EDIT: Okay, try this a test. You don't have to use the merge command, you can just pull master into PersonalSite.

git checkout PersonalSite git pull origin master 

See what gives you. If it says up to date then you have merged correctly.

If you merge stuff locally like you did, then you need to ensure the local tracking branches are up to date. Always specify the branch name to pull from,

git pull origin master git pull origin PersonalSite 
like image 129
sciritai Avatar answered Nov 16 '22 11:11

sciritai


I realize that this is an older question now, but I was just having what I believe is the same problem. I couldn't get it resolved with any combination of the commands in other answers, but I did resolve it by running in the branch that I want merges into:

git checkout <desired_branch_name> -- . 

So for you:

git checkout master -- . 

I found this answer here: git: checkout files from another branch into current branch (don't switch HEAD to the other branch)

like image 24
Carrie Avatar answered Nov 16 '22 10:11

Carrie