Reputation: 101
I have three branches on my local master develop *feature
I want to merge changes of develop branch on to my local feature branch Will git merge develop will work or i have to run some other command
Upvotes: 0
Views: 1688
Reputation: 3752
As mentioned by @Tim, make sure you are on any of the two branches, either develop or feature (from the astreks, you probably are on feature branch), using checkout
command: git checkout feature
or git checkout develop
. Now, that you are on one of the branches, you can ask git to merge them using merge
command. The merge command will try to do automatic merge between the two branches. If it succeeds cleanly, it will create a commit of the resulted merge (the commit will be on the branch you ran the merge command). If it fails, it will stop merge, and tell you the files that have conflict (you can also see the list of unmerged files using git status
).
You can resolve the conflicts either using git mergetool
or manually. The former - mergetool - is provides a GUI interface to resolve conflicts which is a nice thing. Run git mergetool --tool-help
to see a list of available programs. I recommend using p4merge. If you don't have it available, you will need to configure git to use it. I'll add a link to tutorial at the end of my post showing how to do so. If you are going with the latter - resolving conflicts manually -, then you need to know a couple things:
Git marks conflicts in files with a marker like this:
<<<<<<< HEAD:index.html
please contact us at [email protected]
>>>>>>> anotherbranch:index.html
The part before ===== is from the HEAD (the branch you ran the merge from) -- and I have no idea why it's in bold, the part after is from anotherbranch
. You should replace the two parts with the desired string and remove the markers (the <<<<, ==== and >>>).
After that, you use git add <file>
to mark the file as resolved. Then commit after finishing resolving all conflicts.
You might need to read this post from git tutorial on merging to have a better understanding.
Upvotes: 1