Tuesday, December 16, 2014

Creating a new Branch in SourceTree

Branching is an important feature of any version control system. Branching concept in Git is quite different from the conventional version control systems. In conventional version control systems’ branching involves creating a physical set of files/documents and storing them as a separate copy for that branch.

In Git branching is done in a different logic, Git basically stores all the changes to the repository in the form of commits, and branching is done just by switching the [head] pointer between the commits.

Let us now create a new branch called GitCommands and add a new file Git Commands.docx to the new branch.

1.    Open source Tree.

2.    Before creating the branch, make sure that you are pointing to the main branch [master] branch.

3.    Click on the branch option from the Toolbar.

4.    In the popup, which opens up, give a name to the branch.

5.     You can create the new branch from a specific commit by selecting the commit, here we will leave the default option
6.    The check box “Checkout New Branch” ensures that the [head] switches to the new branch once it is created, this will make sure that any further changes/commits done will be stored under the new branch created. Uncheck this if you want to continue working with the old [master] branch.
7.    Click on “Create Branch”
8.  Notice that the current branch is switched to the newly created [GitCommands] branch.

9.    Now let us add a new document “Git Commands.docx” to this branch.
10.    The local working folder will not be pointing to the new branch “GitCommands”, hence when we add a new file and commit the changes will get committed in the new branch.
10. Let us add a new file to the working folder, add, stage and commit the file to the repository.

Search Flipkart Products:

No comments: