Git Branching and Forking

Git Branching and Forking

In this article you will know all about branching, forking and how to use them.


Fork vs Branch vs Clone

Branch -- Is simply a copy of the code in another copy of your code which can be created for a feature to be added in the application or any other modifications without affecting the main code. In later phase the branch can be merged with the master branch. For example branches can be created for different developers to keep it isolated

Clone -- Is copying the code to your local machine or to your account repository with no relation with the original remote repository.

Fork -- Is like cloning but it keeps an information about the relation between this copy and original repo. Then it can be pushed to original repo but it will be reviewed first by original developers before applying the changes. You will have in you local the main remote to your repo and another remote URL to the original repo you forked the code from.


Git Branch Command

Create new branch

Git branch branch-name

Push branch to be available in the main remote

git push origin branch-name  // After creating it using previous command


Git Sync

To keep your branch or repo up to date you can use below command which equivalent to "svn up" in SVN.

git fetch //Without doing merge

git fetch upstream // for upstream branch

git pull // This will do a fetch and yet merge it



Subscribe to
for video tutorials updates