

The HEAD should now be pointed to testbranch1 rather than master as we saw earlier.Ġ807c9a (HEAD -> testbranch1, origin/master, origin/HEAD, master) Adding test files a b c We can confirm whether we are indeed inside our new branch by running any of the below commands. The command "git checkout -b testbranch1" is a shortcut to create a branch and get inside that new branch - Basically one single command instead of the above two. The command "git checkout testbranch1" will take you inside that branch The command "git branch testbranch1" will create the branch Actually creating a branch and getting inside that branch is two seperate commands. Any work done from this point onwards will be part of this new branch. The above shown command will create a branch named testbranch1, and will take you inside that new branch. This can be achieved by running the below commands. Let us create one branch now inside this repository. And the above command also shows us that there are two commits in this master branch, with their respective commit messages. The HEAD is pointing to master, meaning we are currently inside master branch. Once we clone the repository, let us get inside the test-repo directory, and see the commits and current branch we are in.Ġ807c9a (HEAD -> master, origin/master, origin/HEAD) Adding test files a b c Remote: Total 6 (delta 0), reused 3 (delta 0), pack-reused 0 Remote: Compressing objects: 100% (3/3), done.

It has just one single branch (ie: the default branch master), and 2 commits in that branch. Well this a repository i created for pure illustration purposes.

The below will clone an existing repository named "test-repo". Clone the Repository and create few branches Let us create a repository with few test files, and also create and delete few branches. Once your changes from a branch is merged to the main line of development, it actually is quite useless, unless you are actively using it for further development.īeing said that.Keep in mind that deleting a branch won't improve performance or disk utilization (this is because git branches are nothing but pointers to a specific commit id - the last commit id of the source branch from where you created the new branch) Being said that, it is a common practice among users of git, to delete branches that have been merged to main line development (master branch in most cases.Well it depends on your git repository structure.)ĭeleting a branch is a good idea because… Different people have different opinion about deleting a branch. This article will dig through the delete operation of a branch in git. Unlike other version controlling tools, switching between branches is lightning fast in Git. Although many other version controlling tools offer branching feature, none of them implemented branching in the manner git implemented it (it is extremely light weight). It is distributed in nature, it is decentralized, you can do almost every operation locally (meaning connectivity is only required while pushing the changes).Īnother killer feature git offers is “branches”. There are many reasons for its popularity and adoption. The one single tool that dominates the version controlling space is none other than GiT.
