Thursday, April 27, 2017

Creating a branch



You can create a branch using:

git checkout <branch_name>

This will create a branch from current working branch. You can check your current working branch by running:
git branch

If you have multiple branches your current branch is the one which is marked with * at the beginning.

If you want to create a branch from some other existing branch then you can do:

git checkout -b <branch_name> <from_branch_name>

This will create a new branch from the given branch.

The advantage of creating branch is you can work on your changes without affecting other people who are also making changes.
Once you are done with your work then you can merge it back to the main branch. The main branch in git is referrred to as master.

No comments:

Post a Comment

Overriding a remote branch in git

If you need to override a remote branch with local changes, then you can use: git push -f This is very useful whenever you need to disc...