Learning git… mostly messing up!

Abhishek Prasad
2 min readOct 21, 2017

So Hacktoberfest got me hooked onto the awesomes of git and how efficient and cool it is.. Also just how painful it can be.

I will try and make a certain aspect of git easy for you. Also some revelations incoming.

Lets follow this convention:Your username: mr-contributorThe repository you want to contribute to: jupiter/sprite-ng (I have a bottle of sprite next to me, dont judge!)

The start

So you want to contribute and you have found a good project for you to work on.

You fork the repository and not you have a repository mr-contributor/sprite-ng

Now you’ll have to clone it in your PC/Mac/Laptop.

$git clone https://www.github.com/mr-contributor/sprite-ng

Once you’ve done that you start working in your local repository, it’s a good practice to never work on the master branch. Make it a rule to always make a new branch and then code there.

$git checkout -b DevBranch

This creates and goes to the newly created branch.

Let’s say you have done all the bug fixes. Now merge the branch with the master branch. Taking into consideration that there are no changes made to the master branch….. But what the hell, suppose you make changes to your master branch.

$git pull //solve any conflicts that appear
$git checkout master
$git merge DevBranch

Now you have successfully made changes to your local repo.

But wait! Someone has made changes to the main repo(also known as upstream)

Generally here is what we do. I’ll explain as we go along.

$git remote -v //here you will see that no upstream branch is added
$git remote add upstream https://www.github.com/jupiter/sprite-ng
//now the upstream is added
$git fetch upstream //usually the updated code is in upstream/master branch
$git merge upstream/master //take care of conflicts.
$git commit -m "Why did you change the files?!! :angry: "
$git push

By this time, you’ll learn a heck lot about git and how easy it is(sometimes) to contribute to open source.

This is Abhishek Prasad and if this has been helpful to you, subscribe.
If there is anything wrong in the content, please let me know in the comments, I’ll make sure to make the corrections.



Abhishek Prasad

Full-stack software engineer @carsomeMY , newbie lifter, still trying to figure things out and sow things to reap