简体   繁体   English

git登录ssh远程存储库

[英]git log over ssh remote repository

I want to create a git (web) browser, hence I need to iterate over commits ( git log ) on remote repository which is on ssh connected machine. 我想创建一个git(web)浏览器,因此我需要遍历ssh连接机器上的远程存储库上的提交( git log )。 My repo is quite big and constantly changing, therefore I will be interested in not fetching changes locally only to git log them. 我的仓库很大,而且不断变化,因此,我将感兴趣的是不要仅在git log获取更改。

I have tried with: 我尝试过:

git remote add origin ssh://example.net/repo
git checkout -b master --track origin/master

and it failed :\\ 失败了:\\

Any hints how to do that? 有什么提示怎么做吗?

You could push the log to the web server using a hook. 您可以使用挂钩将日志推送到Web服务器。 On the repository host create a script: 在存储库主机上,创建一个脚本:

repo.git/hook/post-receive

where repo.git is your repository path. 其中repo.git是您的存储库路径。 If anyone pushes to this repository the hook will be triggered and it could dump git log to file and send it to the web server over ssh. 如果有人推送到该存储库,则挂钩将被触发,并且可以将git log转储到文件中并通过ssh发送到Web服务器。

The solution has advantage that anyone having access to web server wouldn't get immediate access to the repository. 该解决方案的优势在于,任何有权访问Web服务器的人都不会立即访问该存储库。

On the remote machine, cd to your repository and do a git instaweb . 在远程计算机上, cd到您的存储库并执行git instaweb That will start up a web server that you can access which will contain logs and all other things which are generally used. 这将启动一个您可以访问的Web服务器,其中将包含日志和通常使用的所有其他内容。 git help instaweb for details. git help instaweb以获得详细信息。

You can try to run git log over ssh in a cronjob: 您可以尝试在cronjob中通过ssh运行git log:

ssh example.net git --git-dir=repo log > /tmp/repo.log

This way you don't need to create local repository copy. 这样,您无需创建本地存储库副本。 This assumes you have ssh keys set up and feel safe with this configuration (someone with access to web server could potentially gain access to the repository). 假设您已设置ssh密钥,并且使用此配置感到安全(可以访问Web服务器的人可能会访问存储库)。

您引用的命令出现错误的原因是,添加远程origin/master后需要运行git fetch origin来创建远程跟踪分支origin/master

Having to fetch to do git log does not always work. 必须获取以执行git log并不总是有效。 - I have a large repo that I rarely update so I only clone when I need to make a change. -我有一个大型仓库,很少更新,因此只有在需要更改时才克隆。 But I'd like to keep up with changes to it. 但是我想跟上它的变化。 - I just pushed. -我推。 I'd like to double check the remote repo got my change. 我想再次检查远程仓库是否得到了我的更改。 and I dont have ssh access but do have git access to the machine. 而且我没有ssh访问权限,但确实有git访问权限。

It seems obvious that: 似乎很明显:

GIT_DIR=node:/path/to/repo.git git log

should work for a restricted set of git log switches. 应该适用于一组受限的git日志开关。

It's one of the few holes in git today, IMHO. 恕我直言,这是当今git中为数不多的漏洞之一。

If you would like to run git log localy you will need to clone the repository (isn't that what you were trying to do?): 如果要在本地运行git log ,则需要克隆存储库(这不是您要尝试的操作吗?):

git clone example.net/repo

Disadvantage is that it will take space to store it on the web server, but any future pull will download only new changes and may be quite fast and will depend on size of changes: 缺点是将它存储在Web服务器上需要一定的空间,但是以后的任何拉动都只会下载新的更改,并且可能会很快,并且取决于更改的大小:

cd repo
git pull

You could make the pull either in crontab or even trigger it from repository host using hook to update it only when needed. 您可以在crontab中进行pull ,甚至可以使用钩子从存储库主机触发pull ,仅在需要时才进行更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM