Records about git branch management

I have encountered some problems when using git recently, please record them after solving.

About deleting branches

Want to delete the branch named dev:

// 删除远程分支
git push origin --delete dev
// 删除本地分支
git branch -D dev

But if a branch is deleted on the remote repository, this command will not delete the local remote tracking branch.
At this time, you can view the remote repository through git remote show origin . At
this time, there is another command git remote prune to delete the local The invalid remote tracking branches on the repository

The specific usage method is as follows

//  查看需要清理的分支有哪些
git remote prune origin --dry-run
// 看到之后继续使用下面这条命令
git remote prune origin

In this way, the cleanup of invalid remote tracking branches is completed.

Guess you like

Origin blog.csdn.net/qq_34571940/article/details/107981383