When using Git, listing local branches is a common task that can be easily accomplished with the following command:
bashgit branch
This command displays all local branches in the current repository. The current branch is indicated by an asterisk (*) preceding it.
Additionally, if you want to view more details about each branch, such as the latest commit, you can use the command with parameters:
bashgit branch -v
This command not only lists all local branches but also shows the summary of the latest commit for each branch. This is very helpful for quickly checking branch status.
For example, if you are developing a feature on the feature branch and need to ensure that the master branch is up-to-date, you can first use the git branch command to view all local branches and confirm you are on the feature branch. Then switch to the master branch, pull the latest changes, and return to your feature branch to continue development.
These basic Git commands are essential and effectively help you manage and navigate your branches.