如何执行Git命令而不在存储库中? [英] How do I execute a Git command without being in the repository?

查看:138
本文介绍了如何执行Git命令而不在存储库中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以在不存在仓库的情况下执行Git命令?



例如: git / home / repo log



请不要告诉我 cd 给它。我通过 exec 调用来做到这一点。

试试:

  git --git-dir = / home / repo / .git log 

将路径一直指向存储库的.git目录很重要。否则,您只会收到一条类似以下内容的错误消息:

 致命:不是git存储库


Is there a way to execute Git commands against a repository without being in that repository?

For example something like this: git /home/repo log?

Please do not tell me to cd to it. I'm doing this via an exec call.

解决方案

Try:

git --git-dir=/home/repo/.git log

It is important to give the path all the way up to the .git directory of your repository. Otherwise you will get only an error message that says something like:

fatal: Not a git repository

这篇关于如何执行Git命令而不在存储库中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆