4

Is there a way to look at just the log on a remote git repository without cloning it? How about viewing just a single file?

JellicleCat
  • 28,480
  • 24
  • 109
  • 162
  • To only checkout/view a single file, this thread might be helpful: http://stackoverflow.com/questions/2466735/checkout-only-one-file-from-git – Yavar Jan 01 '13 at 00:26
  • 1
    Git generates logs and diffs and such on the fly, so "no" to the log. Tou don't have to do a full clone if the file you want is in a tagged or branch-head commit, see [this answer](http://stackoverflow.com/a/14104810/1290731) – jthill Jan 01 '13 at 01:40

1 Answers1

1

first off,

if the site hosting the repo has some git visualization layer (github is a website that allows you to browse the contents of an entire repo) than yes. just go to the project page and navigate to the file. when viewing that file (on github) there's a history button the top right of the page. this will show you each commit the file was changed on. or click the blame button, and look at the file line by line and see it's changes.

but if it's just a bare git repo, than no. you will need to clone the entire thing to read the history via log.

but it is possible to clone a repo with only the last commit

git clone -n git://path/to/the_repo.git --depth 1

if you change the value of the depth flag to 2, you'll get two commits and so on.

then if you want to can just checkout a single file

cd repo_name

git checkout HEAD some_filename

xero
  • 4,077
  • 22
  • 39