Search code examples
gitsmartgit

Which action to take in order to preserve master changes and also merge with my changes


I'm working with Git and I learned a lot but somethings still on learning process. I'm working with SmartGit client on Windows.

In master branch, another developer made some changes on the same file I did (see image). Today I made a commit to my working tree and then made a pull request, and here goes the problem since the file entered conflict mode.

So what is the action to take on this case to maintain both code: master branch and my code? Any advice?

enter image description here


Solution

  • git pull --rebase
    

    That will result in a merge conflict, assuming you have git setup to use your tool of choice for merge conflict resolution, you can then type:

    git mergetool
    

    That should launch your merge resolution tool of choice. Just deal with the merge and save the result. When done do:

    git rebase --continue
    

    If there are multiple conflicts you may have to go through this process multiple times to get through them all. Once the rebase finishes you will be cleanly committed on top of master.

    In the case of Smart Git, to do the git pull --rebase I mentioned follow the directions here: http://www.syntevo.com/smartgithg/documentation/6/show?page=commands#pull

    Then to resolve the merge (git mergetool) follow the directions here: http://www.syntevo.com/smartgithg/documentation/6/show?page=commands-branch#resolve-conflicts