在没有cd的情况下在git repo上进入目录 [英] Working on git repo without cd into directory

查看:372
本文介绍了在没有cd的情况下在git repo上进入目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我没有cd到该目录时,如何在repo上运行git命令?

ie git branch /repos/myrepo.git

How would I run git commands on a repo when I am not cd'd into that directory?
i.e. git branch /repos/myrepo.git

推荐答案


- git-dir =< path>

设置存储库的路径。这也可以通过设置GIT_DIR环境变量来控制。它可以是当前工作目录的绝对路径或相对路径。

Set the path to the repository. This can also be controlled by setting the GIT_DIR environment variable. It can be an absolute path or relative path to current working directory.

http://www.kernel.org/pub/software/scm/git/docs/git.html

请注意,上面的< path> 指的是实际git目录的路径( project_dir /.git )不只是项目目录( project_dir )。

Note that <path> above means the path to the actual git directory (project_dir/.git) not just the project directory (project_dir).

这篇关于在没有cd的情况下在git repo上进入目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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