22

I was checking the X commits using the following command:

git log --author=<my-name> -<X>

But the problem is that I accidentally pulled code from another repository and added the commits from the repository to my local git repository.

So I cannot use the above command since the new commits contains some other authors.

4

5 回答 5

36

The command

git log origin/master..master

shows the commits that are on master but not on origin/master.

于 2013-01-04T09:39:31.900 回答
3

I made an alias for this command that lists the commits that have not been pushed.

git log --branches --not --remotes --decorate --oneline

which is a variation of a command cxreg posted in Viewing Unpushed Git Commits.

Lots of other useful ways to parse the commit tree in that post as well.

于 2013-01-05T06:38:06.863 回答
1

The treeish..treeish notation works exactly to see the commits that are present in the second reference, but not in the first one. From the git log help:

A regular D..M computes the set of commits that are ancestors of M, but excludes the ones that are ancestors of D. This is useful to see what happened to the history leading to M since D, in the sense that "what does M have that did not exist in D".

Using this with either git log or git show you can output a list that contains a single line for each commit pressent in the D..M difference:

git show -s --oneline branch..HEAD

or

git log --oneline branch..HEAD

Pair that with a word count and you can output exactly the number of commits you are looking for:

git log --oneline branch..HEAD | wc -l
于 2013-01-10T23:57:38.473 回答
0

This question has be answered already in another post:

git log origin/master..HEAD

(see Viewing Unpushed Git Commits)

于 2014-08-08T10:08:32.253 回答
-1

I use this:

git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative

It shows commits as a graph, with all the branches and their names.

My advice is to create alias for it in ~/.gitconfig

于 2013-01-04T09:40:24.507 回答