Git branch is as cool as tree branch

While working on my next task that was to integrate messages from datagrepper into fedora packages, I learnt few cool stuff about github. I had to change the styling of the datagrepper messages. So, Ralph asked me to make changes and commits in a new branch rather than the develop branch in which I was working before.
If we do not want to make any changes in our master branch (i.e. develop), we can create a new branch that will be a copy of the master branch, then make changes to it and create pull request on this branch. Also for the services that are already working in production, we work on branches only.

How to create a new branch?

I created a branch named fedpkg

Create a new branch on your local machine:

$ git branch fedpkg

Push the branch on github:

$ git push origin fedpkg

Then switch to your new branch:

$ git checkout fedpkg

To see all the branches that have been created:

[charul@localhost datagrepper]$ git branch
* develop

To remove a local branch from your machine:

$ git branch -d the_local_branch

To delete the branch on github:

$ git push origin :fedpkg

To add a new remote to your branch:
(I have added a new remote named upstream)

$ git remote add upstream

To update the local repository with the github repository:

$ git fetch upstream
$ git merge upstream/master

Push changes from your commit into your branch:

$ git push origin upstream

To check the remotes you have:

(datagrepper)[charul@localhost datagrepper]$ git remote -v
origin (fetch)
origin (push)
upstream (fetch)
upstream (push)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s