我想查看所有本地分支,但不包括远程跟踪引用,例如origin/master
这个命令会显示一个漂亮的图形,其中包括了所有本地和远程跟踪分支:
git log --oneline --graph --decorate --all
在这个命令中,我应该添加/删除哪个标志以仅显示本地分支?
我想查看所有本地分支,但不包括远程跟踪引用,例如origin/master
这个命令会显示一个漂亮的图形,其中包括了所有本地和远程跟踪分支:
git log --oneline --graph --decorate --all
在这个命令中,我应该添加/删除哪个标志以仅显示本地分支?
这将显示所有本地分支。
git log --graph --oneline --branches
从 git log --help
--branches[=<pattern>]
Pretend as if all the refs in refs/heads are listed on the command line as <commit>.
If <pattern> is given, limit branches to ones matching given shell glob.
If pattern lacks ?, *, or [, /* at the end is implied.
所以--branches
足矣。我喜欢添加--decorate
并为整个命令设置一个简短的别名。不确定您需要什么,但可以尝试以下命令:
git log --graph --oneline --branches --not --remotes=*
请注意这可能会过滤掉整个日志(例如,在您有一个最新的分支的情况下,因此您没有本地独有的内容)。请查阅 git help log
获取详细信息。
如果您只需要名称和最后一次提交,您可以简单地使用:
git branch -v
您可以混合使用它们来适应您的需求。
但是,我更喜欢使用 gitk --all
,以下是示例输出:
git help log
,在示例部分中您可以找到详细讨论)。 - rlegendi正如其他人所提到的,问题并不是非常清晰明确,但是如果像我一样,你真正想做的是只对本地分支进行修饰,而保留远程分支的未修饰状态,那么可以使用以下调用的变体:
git log --graph --oneline --decorate-refs=refs/heads
其中关键参数为--decorate-refs=refs/heads
。
例如,这将导致从
(base) jdoubled@aig35 ~/packages/solarized $ git log --graph --decorate --pretty=oneline --abbrev-commit --all -n9
* 7ef17bf (HEAD -> topic_demoX) this demos going great
* b583669 (master) stupid empty commit for illustration only
* e40cd41 (origin/master, origin/HEAD) add tmux by @seebi!
* ab3c564 Merge pull request #256 from sgerrand/add-credit-for-xfce4-terminal-port
|\
| * 4f90b03 Adds attribution for Xfce terminal port. Fixes #255.
* | 8a909d3 merge upstream xfce4-terminal changes
* | 04583c9 merge upstream gedit changes
* | f9e5943 add gedit back as a subtree
* | 53bfffc remove gedit submodule
目标:(请注意e40c上没有'origin/master')
(base) jdoubled@aig35 ~/packages/solarized $ git log --graph --decorate --pretty=oneline --abbrev-commit --all -n9 --decorate-refs=refs/heads
* 7ef17bf (topic_demoX) this demos going great
* b583669 (master) stupid empty commit for illustration only
* e40cd41 add tmux by @seebi!
* ab3c564 Merge pull request #256 from sgerrand/add-credit-for-xfce4-terminal-port
|\
| * 4f90b03 Adds attribution for Xfce terminal port. Fixes #255.
* | 8a909d3 merge upstream xfce4-terminal changes
* | 04583c9 merge upstream gedit changes
* | f9e5943 add gedit back as a subtree
* | 53bfffc remove gedit submodule
--decorate-refs-exclude=refs/remotes/<remote_name>
也可以起作用。 - Shiva Prasad
git log --oneline --graph --decorate $(git branch | tr -d ' *' | awk '{ print "master~1.."$0 }')
--decorate
选项。 - cambunctious