Introduction
This article has a strong relation with the application development cycle. It has a purpose for checking the active current branch inside a Git-based repository. Normally, there is no information that can describe or explain a Git-based repository folder just by taking a short peek. But using a certain command, it will reveal the active branch of a Git-based repository. This article will provide an example using a Git-based repository in a local machine where that Git-based repository available by cloning a Git-based repository available in a private Gitlab repository.
First of all, in order to be able to display the branch name of the Git-based repository, there will be a need to install the Git utility client. Using the available Git utility client, it will be useful to retrieve the branch name of the Git-based repository. Just clone any repositories available in any Git-based repository. This article is using a private Gitlab repository. But any Git-based repository online such as the repository exist in github.com or gitlab.com will do. Actually, cloning the repository will affect the branch used. Normally, it will clone the ‘master’ branch.
Usage Example
After successfully cloning any Git-based repository, just try to execute the following command every time there is a need to make sure what is the current branch in the repository. The following is the command pattern :
git branch
For an example, the execution of the above command will exist as follows :
user@hostname:~/repository/apps/myapp$ git branch * master user@hostname:~/repository/apps/myapp$
So, according to the output of the command execution above, there is a specific information about the name of the current active branch. That current active branch name is ‘master’. By default, every Git-based repository has a ‘master’ branch. The output of the above command execution can be vary depends on the repository itself. It can display the ‘master’ branch but it can also display another branch name.