Commit history on remote repository

2019-01-04 16:54发布

I am trying to access a branch's commit history on a remote repository. I had a look at the doc but could not find any substantial information on how to access a remote repo's commit history using my local git client.

标签: git git-log
7条回答
迷人小祖宗
2楼-- · 2019-01-04 17:31

I don't believe this is possible. I believe you have to clone that remote repo locally and perform git fetch on it before you can issue a git log against it.

查看更多
家丑人穷心不美
3楼-- · 2019-01-04 17:36
git log remotename/branchname

Will display the log of a given remote branch in that repository, but only the logs that you have "fetched" from their repository to your personal "copy" of the remote repository.

Remember that your clone of the repository will update its state of any remote branches only by doing git fetch. You can't connect directly to the server to check the log there, what you do is download the state of the server with git fetch and then locally see the log of the remote branches.

Perhaps another useful command could be:

git log HEAD..remote/branch

which will show you the commits that are in the remote branch, but not in your current branch (HEAD).

查看更多
干净又极端
4楼-- · 2019-01-04 17:38

You can only view the log on a local repository, however that can include the fetched branches of all remotes you have set-up.

So, if you clone a repo...

git clone git@gitserver:folder/repo.git

This will default to origin/master.

You can add a remote to this repo, other than origin let's add production. From within the local clone folder:

git remote add production git@production-server:folder/repo.git

If we ever want to see the log of production we will need to do:

git fetch --all 

This fetches from ALL remotes (default fetch without --all would fetch just from origin)

After fetching we can look at the log on the production remote, you'll have to specify the branch too.

git log production/master

All options will work as they do with log on local branches.

查看更多
我命由我不由天
5楼-- · 2019-01-04 17:42

This is what worked for me:

git fetch --all 
git log production/master

Note that this fetches from ALL remotes, i.e. potentially you "have to clone 2GB worth of objects just to look through the commit logs".

查看更多
我欲成王,谁敢阻挡
6楼-- · 2019-01-04 17:46
git remote add origin <remote reference>
git fetch
git log origin/master
查看更多
混吃等死
7楼-- · 2019-01-04 17:47

You can easily get the log of the remote server. Here's how:

(1) If using git via ssh - then just login to the remote server using your git login and password-- and chdir the remote folder where your repository exists- and run the "git log" command inside your repository on the remote server.

(2) If using git via Unix's standard login protocol- then just telnet to your remote server and do a git log there.

Hope this helps.

查看更多
登录 后发表回答