Git Conflict resolution made simple

Have you ever tried to merge a Pull Request and it seems to have a conflict on file that you changed intentionally?

When it comes to conflict resolution, it can be a painful experience sometimes, even when you all you’re doing is accepting the incomin…


This content originally appeared on DEV Community and was authored by José Muñoz

Have you ever tried to merge a Pull Request and it seems to have a conflict on file that you changed intentionally?

When it comes to conflict resolution, it can be a painful experience sometimes, even when you all you’re doing is accepting the incoming changes.

Git can be intimidating sometimes, and most people tend to prefer a GUI to manage their versioning and source control. But sometimes using the CLI can be the better option.

I’m the kind of weird that likes to do things on the CLI when possible, so I have a small life-hack that has saved me so much time during conflict resolution.

In this example we are going to imagine we are trying to make a PR from development to staging, once you’ve created the PR you notice there is a few conflicts and the PR can’t be merged right away. Don’t panic, we can fix this with the power of the CLI!

Make sure you have the latest version of your destination branch (in this case staging) checked out on your local environment.

Go to your source branch (in this case its development) and run:

git pull origin staging —strategy ours

This will accept the history of the source branch over the destination branch and resolve the conflicting files for you. Now you can safely push the resolution to your remote and the PR you submitted should now be mergeable.

The CLI can be an intimidating place, but sometimes it can be the fastest way to achieve a task. Merge strategies are one of the most powerful options you can use from the git source control system, and there’s many more strategies that allow you to get even more flexibility from these options, I’ll leave a couple of links below where you can learn more about git merge strategies, thanks for reading!

Links:


This content originally appeared on DEV Community and was authored by José Muñoz


Print Share Comment Cite Upload Translate Updates
APA

José Muñoz | Sciencx (2021-07-03T19:58:37+00:00) Git Conflict resolution made simple. Retrieved from https://www.scien.cx/2021/07/03/git-conflict-resolution-made-simple/

MLA
" » Git Conflict resolution made simple." José Muñoz | Sciencx - Saturday July 3, 2021, https://www.scien.cx/2021/07/03/git-conflict-resolution-made-simple/
HARVARD
José Muñoz | Sciencx Saturday July 3, 2021 » Git Conflict resolution made simple., viewed ,<https://www.scien.cx/2021/07/03/git-conflict-resolution-made-simple/>
VANCOUVER
José Muñoz | Sciencx - » Git Conflict resolution made simple. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/07/03/git-conflict-resolution-made-simple/
CHICAGO
" » Git Conflict resolution made simple." José Muñoz | Sciencx - Accessed . https://www.scien.cx/2021/07/03/git-conflict-resolution-made-simple/
IEEE
" » Git Conflict resolution made simple." José Muñoz | Sciencx [Online]. Available: https://www.scien.cx/2021/07/03/git-conflict-resolution-made-simple/. [Accessed: ]
rf:citation
» Git Conflict resolution made simple | José Muñoz | Sciencx | https://www.scien.cx/2021/07/03/git-conflict-resolution-made-simple/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.