乐闻世界logo
搜索文章和话题

How do I list only local branches in Git ?

1个答案

1

When using Git, listing local branches is a common task that can be easily accomplished with the following command:

bash
git 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:

bash
git 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.

2024年8月8日 09:27 回复

你的答案