Git - SCM - Resolving merge conflicts in the repo when doing a pull request
Why do you get merge conflicts when doing pull request?
- The target repo you requested to merge using your source branch repo may have commits not synced up properly.
- Example:
How to resolve? Do the following?
- be in your repo which will be merged to the target branch repo
- git checkout <your_source_repo>
- reset all the commits you have made.
- git reset HEAD~x
- where x above mentioned will be the number of commits
- stash all your current uncommited changes or unstashed commits
- git add .
- note that there is a dot (i.e.) "." at the end of add above to stage all the changes
- git stash
- think like a shelf. you just store here temporarily
- pull current latest remote codebase or commits
- git pull origin <target_branch_source_repo>
- pop the ones you stashed to get back all your changes (these will still be unstaged)
- git stash pop
- handle conflicts now in your local branch codebase
- commit your changes
- git add .
- git commit -m "your msg"
- force push your commits to your remote source branch repo
- git push origin -f <your_remote_source_branch_repo>
- That's it. now, your commit history will be in sync.
Comments
Post a Comment