Getting started with Open Source Software

Being up-to-date and avoiding conflicts

Image for post
Image for post

Have you ever wondered how you could collaborate with open-source projects but you didn’t know how to start? It couldn’t be easier. Take a look:

Image for post
Image for post
git clone git@github.com/myself/forked.git
Image for post
Image for post
(master)$ git remote add upstream https://github.com/owner/repo.git# If you run `git remote -v` you should see:
origin git@github.com:myself/forked.git (fetch)
origin git@github.com:myself/forked.git (push)
upstream git@github.com:owner/repo.git (fetch)
upstream
git@github.com:owner/repo.git (push)

Get the last changes in your project (not necessary if you just forked the project).

(master)$ git fetch upstream master
(master)$ git merge upstream/master
(master)$ git checkout -b new-branch
(new-branch)$ git add . # Add to git your changes
(new-branch)$ git commit -m ‘Type the commit message’
(new-branch)$ git push origin new-branch # Push in forked & origin
(master)$ git remote set-url origin git@github.com:myself/forked.git

That’s all!

If your changes (or someone else’s) have been merged in the origin, you need to run fetch upstream master and git merge upstream/master in master to be up-to-date!

To sum up

# Synchronize your local repository to the original one
# Need to run only once the first time
git remote add upstream git@github.com/owner/repo.git
# Get all changes from sync project into upstream branch
git fetch upstream master
# Merge upstream branch into your current branch
git merge upstream/master
Image for post
Image for post

Written by

Competitive, entrepreneur and autodidact. Hard worker, lover of technology and free software.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store