git 如何查看本地未推送的提交?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16323409/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 16:04:04  来源:igfitidea点击:

How do I see my local unpushed commits?

gitgit-svn

提问by user565660

If I have a local branch testand the remote branch is test. So if I did a push it would be push origin test:test

如果我有一个本地分支test而远程分支是test. 所以如果我推动它会是push origin test:test

How can I see my local unpushed commits that I did on that branch? git log?

如何查看我在该分支上所做的本地未推送提交? git log?

回答by Fran?ois

I generally use gitk --allfor that (after a git fetch --all).

我通常使用gitk --all它(在 a 之后git fetch --all)。

And, for console mode, I have an alias of git log --graph --all --decorate --onelinewhich gives a nice and compact overview of your branches. In particular, it shows what you can push.

而且,对于控制台模式,我有一个别名,git log --graph --all --decorate --oneline它可以很好地简洁地概述您的分支。特别是,它显示了您可以推送的内容。

For both these commands you can specify branches (test origin/testin your case) instead of showing them all with --all.

对于这两个命令,您可以指定分支(test origin/test在您的情况下),而不是用--all.

回答by Andomar

First fetch the remote's changes to your local repository:

首先获取远程对本地存储库的更改:

git fetch origin test

This will place all commits from the remote's testbranch in origin/test. Now you can use git log:

这会将来自远程test分支的所有提交放在origin/test. 现在您可以使用git log

git log origin/test..test

That will show all commits on testthat are not reachable from origin/test.

这将显示test无法从origin/test.