Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run `git log` on a remote branch

Tags:

git

github

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 [email protected]: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.

like image 292
MRocklin Avatar asked Sep 06 '12 00:09

MRocklin


2 Answers

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)

like image 101
andy magoon Avatar answered Nov 13 '22 00:11

andy magoon


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 ...
like image 44
Tony K. Avatar answered Nov 13 '22 02:11

Tony K.