首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >是否有更好的方法来确定是否存在本地GIT分支?

是否有更好的方法来确定是否存在本地GIT分支?

提问于 2018-03-26 00:54:45
回答 2关注 0查看 109

我使用下面的命令来查找局部GIT分支branch-name存在于我的存储库中。这是对的吗?有更好的办法吗?

请注意,我是在脚本中这样做的。出于这个原因,如果可能的话,我想远离命令。

代码语言:txt
复制
git show-ref --verify --quiet refs/heads/<branch-name>
# $? == 0 means local branch with <branch-name> exists. 
代码语言:txt
复制
git rev-parse --verify <branch-name>
# $? == 0 means local branch with name <branch-name> exists.
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档