Viewing Unpushed Git Commits

2018-12-31 13:49发布

How can I view any local commits I've made, that haven't yet been pushed to the remote repository? Occasionally, git status will print out that my branch is X commits ahead of origin/master, but not always.

Is this a bug with my install of Git, or am I missing something?

24条回答
看淡一切
2楼-- · 2018-12-31 14:19
像晚风撩人
3楼-- · 2018-12-31 14:19

one way of doing things is to list commits that are available on one branch but not another.

git log ^origin/master master
查看更多
人间绝色
4楼-- · 2018-12-31 14:21

This worked better for me:

git log --oneline @{upstream}..

or:

git log --oneline origin/(remotebranch)..
查看更多
明月照影归
5楼-- · 2018-12-31 14:22

If you want to see all commits on all branches that aren't pushed yet, you might be looking for something like this:

git log --branches --not --remotes

And if you only want to see the most recent commit on each branch, and the branch names, this:

git log --branches --not --remotes --simplify-by-decoration --decorate --oneline
查看更多
美炸的是我
6楼-- · 2018-12-31 14:23

I use the following alias to get just the list of files (and the status) that have been committed but haven't been pushed (for the current branch)

git config --global alias.unpushed \
"diff origin/$(git name-rev --name-only HEAD)..HEAD --name-status"

then just do:

git unpushed
查看更多
君临天下
7楼-- · 2018-12-31 14:24

You could try....

gitk

I know it is not a pure command line option but if you have it installed and are on a GUI system it's a great way to see exactly what you are looking for plus a whole lot more.

(I'm actually kind of surprised no one mentioned it so far.)

查看更多
登录 后发表回答