主人和分支之间的信息前/后信息? [英] git ahead/behind info between master and branch?
问题描述
我在本地仓库( test-branch
)中创建了一个分支,我推送到 Github
。
如果我转到我的 Github
帐户并选择 test-branch code>它显示了信息:
这个分支是1个提交,2个提交后面
我的问题是:
- 我怎样才能在本地显示这个信息(即:在终端上显示这个信息的命令,而不是打开
Github
来查看它)?
-
我知道我可以在分支之间看到差异:
git diff master..test-branch
或使用
Meld
(我更喜欢) :git difftool master..test-branch
但我想知道是否有方法可以单独提交前面和后面 。 IE:有没有办法显示 1自己提交本身,然后那些 2自己提交?
这是我发现的比较两个分支(任意两个)的技巧,并显示每个分支提前多少提交(对你的问题1更一般的答案):
$ b $ g $ git rev-list --left-right --count master ... test-分支
它给你输出的结果如
1 7
这意味着:与master相比,test-branch提前7次提交,后面1次提交
您还可以比较分支,如 origin / master ... master
,以了解分支在其远程前/后的提交数量分行
I have created a branch for testing in my local repo (test-branch
) which I pushed to Github
.
If I go to my Github
account and select this test-branch
it shows the info:
This branch is 1 commit ahead and 2 commits behind master
My questions are:
- How can I display this info locally (ie: a command that shows this on the terminal, rather than having to open
Github
to see it)? I know I can see the diffs between branches using:
git diff master..test-branch
or using
Meld
(which I prefer):git difftool master..test-branch
but I was wondering if there's a way to see the ahead and behind commits separately. I.E.: is there a way to show that 1 commit ahead by itself and then those 2 commits behind by themselves?
Here's a trick I found to compare two branches (any two) locally and show how much commits each branch is ahead of the other (a more general answer on your question 1):
git rev-list --left-right --count master...test-branch
which gives you output like
1 7
which means as much as: compared to master, test-branch is 7 commits ahead and 1 commit behind
You can also compare branches like origin/master...master
to find out how many commits a branch is ahead/behind of its remote branch
这篇关于主人和分支之间的信息前/后信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!