Reputation: 40639
I want to know if there is a way on the git command line to copy the branch history from a remote repo. In other words, I want to copy the .git/logs
directory from the remote to my .git/logs
directory -- even if this means overwriting my logs folder.
EDIT:
To clarify further, assuming that there is a branch called foo
on remote called origin
, I want to be able to type:
$ git rev-parse --verify foo@{2}
on my computer and have that output the exact same thing as on origin. This requires more than just looking at git log
.
Furthermore, it is possible for someone to do git update-ref foo foo^
in order to undo a commit, and that history is only preserved in the .git/logs
folder.
Upvotes: 0
Views: 370
Reputation: 22356
The history will replicate with clone. All you need to do is checkout the branch and run log.
Example - Assuming your remote repository is origin
and the branch foo
.
You can run git checkout --track -b foo origin/foo
to checkout and track a remote branch
To get the history, ensure you are in the branch foo
by running git branch
, now type
git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short
and you can see the history of the branch
$ git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short
* 075086d 2012-01-06 | Added for joyent (HEAD, origin/tableUpdate, tableUpdate) [xxx]
* 8352180 2012-01-06 | Added package and loggging [xxx]
* ed9300f 2011-12-26 | Added stylesheet [xxx]
* e8b39fa 2011-12-26 | Increased templating, renamed div to meaningful names [xxx]
If I switch to master it will be different, running git checkout master
and git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short
, I get
$ git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short
* 6402a2e 2012-01-08 | Added README (HEAD, origin/master, origin/HEAD, master) [xxx]
* 292c57a 2012-01-08 | Removed port, this is autodetected [xxx]
* e0ef362 2012-01-08 | Changed port to 8080 and document lookup is dynamic [xxx]
Finally, to prevent your fingers mangling or falling off when typing that long log command. You can create a shortcut, create in your home directory (assuming Unix) ~/.gitconfig
and add the line
[alias]
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
You can then just run git hist
Upvotes: 1