git log我想创建一个 git (web) 浏览器,因此我需要在 ssh 连接的机器上的远程存储库上迭代提交 ( )。我的仓库很大并且不断变化,因此我有兴趣不要只在本地获取更改给git log他们。
我尝试过:
git remote add origin ssh://example.net/repo
git checkout -b master --track origin/master
它失败了:\
任何提示如何做到这一点?
您可以使用挂钩将日志推送到 Web 服务器。在存储库主机上创建一个脚本:
repo.git/hook/post-receive
repo.git您的存储库路径在哪里。如果有人推送到这个存储库,钩子将被触发,它可以将 git log 转储到文件并通过 ssh 将其发送到 Web 服务器。
该解决方案的优点是任何有权访问 Web 服务器的人都不会立即访问存储库。
您可以尝试在 cronjob 中通过 ssh 运行 git log:
ssh example.net git --git-dir=repo log > /tmp/repo.log
这样您就不需要创建本地存储库副本。这假设您已经设置了 ssh 密钥并且对此配置感到安全(有权访问 Web 服务器的人可能会获得对存储库的访问权限)。
必须获取执行 git log 并不总是有效。- 我有一个很少更新的大型存储库,所以我只在需要进行更改时克隆。但我想跟上它的变化。- 我只是推。我想仔细检查远程仓库是否得到了我的更改。而且我没有 ssh 访问权限,但对机器有 git 访问权限。
似乎很明显:
GIT_DIR=node:/path/to/repo.git git log
应该适用于一组受限的 git log 开关。
恕我直言,这是当今 git 中为数不多的漏洞之一。
您引用的命令出错的原因是您需要git fetch origin在添加远程后运行才能创建远程跟踪分支origin/master。
在远程机器上,cd到您的存储库并执行git instaweb. 这将启动一个您可以访问的 Web 服务器,该服务器将包含日志和所有其他通常使用的东西。git help instaweb详情。
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 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:
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.