Skip to content

Instantly share code, notes, and snippets.

@barryblando
Last active December 26, 2017 01:33
Show Gist options
  • Save barryblando/df8433ed7a57a73ce171680c7fe0e50d to your computer and use it in GitHub Desktop.
Save barryblando/df8433ed7a57a73ce171680c7fe0e50d to your computer and use it in GitHub Desktop.
How to Avoid Merge Conflicts

Tip #1 Run the "git pull" command as often as possible

If you're working with a team of other developers you want to constantly be pulling in their commits from the server so that you're working with the latest code you want to make this part of your routine, so running "git pull" just becomes a habit. Any time you sit down to work on your project before you actually edit any files, run a "git pull".

Tip #2 Communicate with your team

Simply communicating with your team can go a long way. Talk with each other about who is responsible for which changes and which parts of the project. Be aware of what each team member is working on for that day or week and you don't need to go overboard and waste a ton of time chatting about what you're working on. But you'd be surprised. Even just having a general idea of what each person is working on will put you in a position where you are far less likely to edit the same lines of code within the same file at the same time and that means less conflicts.

Tip #3 Standardize white space settings in text-editor

Make a plan with your team about what to use in text editor.

Tip #4 Think of "git merge" as a two-way street.

-"git merge" won't help you avoid conflicts outright but if you're working on a feature branch it will help you deal with any potential conflicts before it's time to actually merge feature branch back into master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment