Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I see incoming commits in git? [duplicate]

Tags:

git

dvcs

People also ask

How do I see incoming commits?

use: gitk --all to see.

How do I see my commits in git?

On GitHub.com, you can access your project history by selecting the commit button from the code tab on your project. Locally, you can use git log . The git log command enables you to display a list of all of the commits on your current branch. By default, the git log command presents a lot of information all at once.

How can I see previous commit changes?

To find out which files changed in a given commit, use the git log --raw command. It's the fastest and simplest way to get insight into which files a commit affects.

How do I see more commits in git log?

For example, if you want to see only 1 commit in your git log or you want to see 2 commits or it can be any number depending on the total number of commits you have done in your git repository. The command for that would be git log -n where n represents the number up to which commit you to want to see the logs.


incoming isn't quite a direct mapping in git because you can (and I often do) have multiple repos you're pulling from, and each repo has multiple branches.

If there were an equivalent of hg's incoming command, it'd probably be this:

git fetch && git log ..origin/master

That is, "go grab all of the stuff from the upstream, and then compare my current branch against the upstream master branch."

Similarly, outgoing would be this:

git fetch && git log origin/master..

In practice, I just type those manually (even though I created an alias for one of them) because it's easy to have lots of local branches tracking and being tracked by lots of remote branches and have no trouble keeping it together.


You may also be interested in git whatchanged which gives a good overview of changes that have been made in some range of commits.

If you want to review what you're about to pull, do a git fetch first, which only updates local tracking branches for the remote repository (and not any of your branches), and then use any command that shows you the new commits that you're about to pull. For example:

git whatchanged ..origin

This is shorthand for showing the commits between "the common ancestor of wherever I am now and origin" through "origin".


You may want to examine the difference between two repositories. Assumed you have a local branch 'master' and a remote-tracking branch 'origin/master', where other people commit their code, you can get different stats about the differences of the two branches:

git diff --summary master origin/master

git diff --stat master origin/master

git diff --numstat master origin/master

git diff --dirstat master origin/master

git diff --shortstat master origin/master

git diff --name-only master origin/master

git diff master origin/master

When someone tells you to pull, they will give you the repo URL and a branch (default being master).

I'd just do

git fetch URL branch

followed by one (in decreasing order of preference):

# note 3 dots in next 3 commands
gitk HEAD...FETCH_HEAD
    # shows all commits on both sides since the "fork" point
gitk --cherry-pick HEAD...FETCH_HEAD
    # as above but skips identical patches so you really see the differences
git log --graph --boundary --left-right --cherry-pick --decorate HEAD...FETCH_HEAD
    # I have a nice alias for this; it's the text mode eqvt of the above

I also use "tig" sometimes, but this specific usecase (seeing both sides) is not well served by tig.

However, if you bring it down to two dots (which may match your actual question more closely, though I still prefer the 3 dot versions), you can do

tig HEAD..FETCH_HEAD

Here are the aliases for convenience:

incoming = !sh -c 'git fetch && git log --graph --boundary --left-right --cherry-pick --decorate HEAD..FETCH_HEAD'
outgoing = !sh -c 'git fetch && git log --graph --boundary --left-right --cherry-pick --decorate FETCH_HEAD..HEAD'