I don’t think I’m alone in saying this; early in my career, merge conflicts were the bane of my existence (particularly in 2019). I graduated from ...
For further actions, you may consider blocking this person and/or reporting abuse
I am glad that I can use a proper IDE, working with JetBrains-IDEs make this stuff so much easier, where you have full Git integration with a proper side-by-side diff-view and can apply or dismiss changes with a single click.
Using Jetbrains products' git integration is like having a dishwasher instead of doing dishes by hand. You really can't live without it once you have it, because it makes life so easy! It's simply amazing!
Oh wow! Okay, I'm sold!
Interesting! I'll have to look into how JetBrains does it. I wouldn't describe VS code as hard. They have the option to see it side by side. You can apply and dismiss the changes in one click there as well, but if you're newer to version control ..the terminology of "current changes" or "incoming changes" can seem confusing.
Here's a post about the different ways to handle merge conflicts in different IDEs..might be interesting to compare those to JetBrains: betterprogramming.pub/how-to-resol...
I think this is THE reason why I've never really switched to VSCode. And I cannot understand why is so difficult to provide a plugin that handles the conflicts like JetBrains-IDEs do.
I mean, there's gitlens on VScode.. you can compare your code with the last commit and easily handle conflicts.
My last group project in my coding bootcamp was a nightmare only because daily we were having merging conflicts, so it's safe to say the fear is now gone lol! But this article did provide some new insight to how to better manage and prevent these hiccups from happening in the first place! Not always avoidable, but definitely manageable. Thank you Rizèl ✨
Lol, glad you got that experience in your group. While it was probably frustrating, now you're more prepared for future situations. Definitely manageable, and there's actually ways to avoid it or have less merge conflicts. Maybe I will write about that soon. And thank you for reading and commenting!
Whaaatt??!! Then yes, yes, yes please write about it! And of course your content is engaging and informative, best of both worlds!
Just be glad you didn't use Microsoft Visual SourceSafe. The merging was ok for the time but having to chase down someone on holiday to unlock a checked out file was a nightmare. Then the "database" would corrupt.
LOL I'm grateful I never experienced that
Awesome and helpful writeup😃💯
I'm glad it was! Let me know if you have any other questions.
Update: here's my thoughts on preventing merge conflicts -
dev.to/github/how-to-prevent-merge...
A few principal notes.
1. You (among with most of such recipesʼ authors) have omitted one principal thing: in a complex case, to understand how a conflict should be resolved, you might see an original base of each conflicting chunk. To make it visible in conflicts, use setting:
git config merge.conflictStyle diff3
(you may add--global
for global setting).This will add a new section, like in the following example:
original:
version1:
version2:
After merge attempt:
You see new section after
||||||||
- this is the common base.Not only a human gets aid from it - this is crucial for automated merge tools.
2. Next: use automated merge tools. There are lots of them: kdiff3, vimdiff... They have two merits: 1) they are deliberately smarter than default git logic and may resolve conflicts that git retains unresolved; 2) they provide visual interface to merge.
For a command in git, this is
git mergetool
(shall be configured, what tool to run).3. Use aid to understand what change is applied now to make the conflict. Depending on operation, this could be
git status
plusgit show
for specified commit id (shows the applied patch - typical for rebase),git am --show-current-patch
(I use aliasgit amsh
for it; used for cherry-pick as well).4. Notice that sometimes git misdetects what chunks to compare. You might need editor to relocate code blocks to realize the proper relation between chunks. I usually experienced this in case of sequence of small methods when something is inserted inside the sequence.
+1 to calling in the other author you're conflicting with. on the command line a merge conflict looks and is arcane, cryptic, and math-heavy. but the reality is that it's just you and another person collaborating asynchronously.
You worded that well!
Good article! It might be worth mentioning that as well as accepting current and/or incoming changes you can just grab code from each change and manually edit what you want to keep/remove (at which point manually removing the change indicators is also required).
Obviously the best strategy is to avoid merge conflicts in the first place. That's achieved by careful planning; good communication between team members; and can also be mitigated by keeping up with the base branch (i.e. rebasing regularly).
How to handle merge conflicts in Pulling remote changes to a local repository ? powerful dua for marriage with a loved one
I switched from Vscode to Meld to solve conflicts, give it a try: it's very handy and visual
You can comment here also:
eccco.space/s/cadf73c1-1900-4fe8-a...
I have used P4Merge tool to resolve conflicts. Give it a try.
perforce.com/products/helix-core-a...
I hate git conflict , 1 hour to add feauture in your project and 7 hour to resolve conflicts
Hopefully, this post helps to reduce that time. I'll write a post about how to prevent merge conflicts in the future.