git显示和查找分支
本文梳理了如何查看和查找本地分支。
git show-branch#
GIT-SHOW-BRANCH(1) Git Manual GIT-SHOW-BRANCH(1)
NAME
git-show-branch - Show branches and their commits
SYNOPSIS
git show-branch [-a|--all] [-r|--remotes] [--topo-order | --date-order]
[--current] [--color[=<when>] | --no-color] [--sparse]
[--more=<n> | --list | --independent | --merge-base]
[--no-name | --sha1-name] [--topics]
[(<rev> | <glob>)...]
git show-branch (-g|--reflog)[=<n>[,<base>]] [--list] [<ref>]
git branch#
GIT-BRANCH(1) Git Manual GIT-BRANCH(1)
NAME
git-branch - List, create, or delete branches
SYNOPSIS
git branch [--color[=<when>] | --no-color] [-r | -a]
[--list] [-v [--abbrev=<length> | --no-abbrev]]
[--column[=<options>] | --no-column] [--sort=<key>]
[(--merged | --no-merged) [<commit>]]
[--contains [<commit]] [--no-contains [<commit>]]
[--points-at <object>] [--format=<format>] [<pattern>...]
git branch --edit-description [<branchname>]
description#
执行 vim .git/description
可以查看当前仓库的描述:
可以执行 git branch --edit-description [<branchname>]
对指定(当前)branch 的描述信息进行编辑。
等效命令为 git config branch.<branch name>.description
。
例如为 testEmptyApplication 分支添加描述,然后执行 git config -l
可以看到配置中有如下行:
The .git/description
file is only used in the Git-Web program.
list branches#
If --list
is given, or if there are no non-option arguments, existing branches are listed;
the current branch will be highlighted with an asterisk.
Option -r
causes the remote-tracking branches to be listed, and
option -a
shows both local and remote branches.
git branch
等效于 git branch --list
,列举本地 checkout 出来的仓库,当前仓库会以星号 *
标记。
git branch -r
列举远端仓库 remotes/origin/ 下的所有分支。
git branch -a
列举本地(--list
) + 远端(-r
)的所有分支。
- git config -l
- git branch -v
pattern#
git branch --list '*NestFile*'
:本地名称中包含 NestFile 的分支;
git branch --list '*Send*Album*'
:本地名称中包含 Send 和 Album 的分支;
Find Parent Branch#
findParent.sh
who_is_my_mummy.sh
find the parent branch
Git show parent branch
Find the parent branch of a Git branch @stackoverflow
How to find the nearest parent of a Git branch?
git log --decorate \
| grep 'commit' \
| grep 'origin/' \
| head -n 2 \
| tail -n 1 \
| awk '{ print $2 }' \
| tr -d "\n"
针对以上 commit-sha1 再执行 git log -1 查看其 log。
Git First-Parent--Have your messy history and eat it too