9

I want the output of git log of a git repository but I don't want to have to clone the entire repository.

I.e. I want something semantically like the following

git log git@github.com:username/reponame.git

If there is a way to do this I'll also want the same for git whatchanged

If github provides a simple solution for this I would be willing to restrict myself to only git repositories hosted on github.

MRocklin
  • 55,641
  • 23
  • 163
  • 235

5 Answers5

8

You should fetch the remote branch then interact with it. git fetch will pull the remote branch into your local repository's FETCH_HEAD, but not your working directory.

git log FETCH_HEAD --decorate=full will let you see where your HEAD is in comparison to refs/origin/HEAD, which is the remote branch.

git whatchanged FETCH_HEAD --decorate=full is the same as above, but also shows the files that have changed.

git diff HEAD FETCH_HEAD diffs between your repository's HEAD and the remote branch's HEAD that you just fetched

git diff --stat HEAD FETCH_HEAD a summary preview of the changes, just as you would see during the merge and at the bottom of a git pull.

Note that if you do wish to pull in the fetched changes, just do a git merge FETCH_HEAD. (When you git pull you are essentially just doing a fetch then a merge)

andy magoon
  • 2,889
  • 2
  • 19
  • 14
  • 1
    This answer is useless wrg of the actual question asked, but I give it an upvote anyway as it solved the problem I wanted to solve when duckduckgoing for "git log remote branch" :-) – tobixen Jun 26 '15 at 06:16
3

You could do a shallow clone, which would limit the amount of stuff you'd have to fetch if you only need the recent history:

git clone --depth 100 ...
Tony K.
  • 5,535
  • 23
  • 27
2

I've found two ways of doing this with GitHub:

  1. Use the web API to query the log information (not trivial but doable)
  2. Use "svn log", since GitHub now partially emulates an SVN server on the Git repositories
Drealmer
  • 5,578
  • 3
  • 30
  • 37
1

I think your solution is to just look at the history on the github.com website. If you need git log to work from the command-line then you need your own clone of the repository.

In theory you could write a command-line tool that pulls down commit information from github's API, but this would be restricted to showing just commit messages/metadata, and not actual diffs.

Lily Ballard
  • 182,031
  • 33
  • 381
  • 347
0

The Unix way is to have a shell account:

ssh user@otherserver cd reponame.git '&&' git log

and

ssh user@otherserver cd reponame.git '&&' git whatchanged

This method has the advantage of running whatever you want on the remote server. I doubt this will work with github though.

Robie Basak
  • 6,492
  • 2
  • 30
  • 34