Tuesday, December 16, 2014

Checkout in SourceTree (switch branches)

In the previous post Creating a new Branch in SourceTree we created a new branch “GitCommands”, we now have 2 branches “master” and “GitCommands” and the [Head] is pointing to the “GitCommands” branch, we will switch from this branch to the “master” branch.

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.

Branch Vs Checkout in Git

Branch and Checkout do the same thing but there is a small difference between the two. This post explains the difference between the operation of the branch and checkout commands in Git.

Deleting a local Repository using SourceTree

There are situations in which you want to totally remove the repository from your local, suppose you have messed up the code in your local copy and want to get rid of the same completely, then you can completely delete the local repository and clone a new copy from the remote repository and start using it.

To delete a local repository use the following steps.

Discarding changes to a file in SourceTree

There are situations in which you have a work in progress code, which you do not want to commit, but want to roll back changes for the previous commit state, Git helps us achieve this using the Discard option.

         When you discard changes in the working / staging area the changes are removed and            the working copy is rolled back to the previous commit state. Discarding changes can be            done as follows.