Facing merge conflicts ? Here is your best way out.

For those who are newbies in the open source world, this is an everyday problem. Even, I go through this frequently. It’s okay, no one in the world knows everything, even the repositories having 3000 stars are having poor commit messages, but the important thing in open source is whatever you are doing should not mess others contributors work. Here are some of the key points you should consider while contributing to open source projects.

  1. Don’t make any changes in master branch.
  2. Master branch is meant for syncing with your upstream.
  3. Whatever changes you make do it in a separate branch and send pull request from that branch to the original repository.

If you do not follow this mantra, you will be flooded with merge conflicts which take almost double the time you spent on making the changes.

Lets start with cloning the repository:

git clone git@github.com:sch00lb0y/yaydoc.git

Switch you path to the cloned repository and add upstream(original repository).

git remote add upstream git@github.com:fossasia/yaydoc.git

Create a new branch to make changes:

git checkout -b dev

Whatever changes you have made until now, commit and push to your remote fork.

git add .
git commit -m "Fixes #23 cleaning folder after doc generation"
git push origin dev

Now send the pull request to the original repository. Your commits will now be reviewed by your peers or the maintainers and then they will be merged. After your request gets merged delete the branch you created and sync your local master branch with upstream master.

git push origin --delete dev // remote deleting
git branch -d dev //local deleting
git checkout master
git pull upstream master

For best practices, check out this blog http://blog.fossasia.org/open-source-developer-guide-and-best-practices-at-fossasia/

Happy Coding

If you like this blog please 💚 it’ll give me motivation to write blog in future

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.