是否有一个Git命令等价于:
git branch | awk '/\*/ { print $2; }'
是否有一个Git命令等价于:
git branch | awk '/\*/ { print $2; }'
当前回答
有人可能会发现这个(git show-branch——current)很有用。当前分支显示为*标记。
host-78-65-229-191:idp-mobileid user-1$ git show-branch --current
! [CICD-1283-pipeline-in-shared-libraries] feat(CICD-1283): Use latest version of custom release plugin.
* [master] Merge pull request #12 in CORES/idp-mobileid from feature/fix-schema-name to master
--
+ [CICD-1283-pipeline-in-shared-libraries] feat(CICD-1283): Use latest version of custom release plugin.
+ [CICD-1283-pipeline-in-shared-libraries^] feat(CICD-1283): Used the renamed AWS pipeline.
+ [CICD-1283-pipeline-in-shared-libraries~2] feat(CICD-1283): Point to feature branches of shared libraries.
-- [master] Merge pull request #12 in CORES/idp-mobileid from feature/fix-schema-name to master
其他回答
的输出可能会让您感兴趣
git symbolic-ref HEAD
特别是,根据您的需要和您可能希望做的布局
basename $(git symbolic-ref HEAD)
or
git symbolic-ref HEAD | cut -d/ -f3-
还有。git/HEAD文件,你可能会感兴趣。
在Git 1.8.1中,你可以使用带有"——short"选项的Git symbol -ref命令:
$ git symbolic-ref HEAD
refs/heads/develop
$ git symbolic-ref --short HEAD
develop
据我所知,没有办法在Git中本地显示当前的分支,所以我一直在使用:
git branch | grep '*'
有人可能会发现这个(git show-branch——current)很有用。当前分支显示为*标记。
host-78-65-229-191:idp-mobileid user-1$ git show-branch --current
! [CICD-1283-pipeline-in-shared-libraries] feat(CICD-1283): Use latest version of custom release plugin.
* [master] Merge pull request #12 in CORES/idp-mobileid from feature/fix-schema-name to master
--
+ [CICD-1283-pipeline-in-shared-libraries] feat(CICD-1283): Use latest version of custom release plugin.
+ [CICD-1283-pipeline-in-shared-libraries^] feat(CICD-1283): Used the renamed AWS pipeline.
+ [CICD-1283-pipeline-in-shared-libraries~2] feat(CICD-1283): Point to feature branches of shared libraries.
-- [master] Merge pull request #12 in CORES/idp-mobileid from feature/fix-schema-name to master
我使用
/etc/bash_completion.d/git
它随Git一起提供,并提供了带有分支名称和参数补全的提示。