0

I have a bare structure of my project. In few words, from local machine I make a push with some commit, go to main server and using pull take all changes.

I always do git status before pulling. And I always have a picture something like this:

On branch 6.0-rfc 
Your branch is behind 'origin/6.0-rfc ' by 5 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)

And I do git pull and everything is ok.

But, how can I view this 5 commits, for example, who made them, what files were changed and so on?

sergio
  • 5,210
  • 7
  • 24
  • 46

1 Answers1

1

To inspect the commits before merging (done automatically by git pull), issue a git fetch, then inspect the HEAD of the branch (likely origin/master) that was updated by the fetch.


If you follow standard branch naming conventions (e.g. master for the local, origin for the remote), your new workflow could look like this:

git fetch origin  # Fetch all commits on the remote side, don't merge to master
git log origin/master  # Inspect the commits on origin's master
git merge origin/master  # Merge the commits into your local branch

When inspecting after the pull, you may also find it helpful to use commit ranges. To see only commits that the origin's master branch would add to your local master:

git log master..origin/master
David Cain
  • 16,484
  • 14
  • 65
  • 75
  • Work day is off, I will check and write. – sergio Jan 09 '14 at 16:14
  • The last two commands should be `git log origin/master` and `git merge origin/master`. – Ash Wilson Jan 09 '14 at 16:16
  • @Ash- sorry, I'm assuming branch tracking of `master` to `origin`, so the `merge` is equivalent with or without the slash (see ["Ramifications of forgetting slash in “git merge origin/branch”](http://stackoverflow.com/a/10589336)). I've changed the commands to be more explicit, though. – David Cain Jan 09 '14 at 16:25
  • Oh, interesting! I've seen a lot of people accidentally make "origin" branches and so on by forgetting the slash; I didn't know git would infer like that. (We might have been on an older git version at that point, too.) – Ash Wilson Jan 09 '14 at 16:32
  • `git log master..origin/master` is what I really need!!Thanks!! – sergio Jan 10 '14 at 07:18