git --git-dir没有按预期工作 [英] git --git-dir not working as expected

查看:114
本文介绍了git --git-dir没有按预期工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  

我试图从不同的目录运行git, cd / home / domain /
git status<<运行完美即
#分支大师
#你的分支在6次提交之前领先于'origin / master'。

所以现在我想使用从不同的目录运行这个命令 - -git-dir 选项。



因此可以说我在 root / 并试试这个:

  git --git-dir =/ home / domain /状态
##错误
致命:不是git存储库:'/ home / domain /'

还试图包含 .git 文件夹,即

  git --git -dir =/ home / domain / .git /status 

但是这看起来像是试图从根目录运行git,即删除我的域名文件夹中的所有内容,并在根目录中添加所有内容。



希望有人可以告诉我我做错了什么。

解决方案

您还必须定义工作目录。

  git --git-dir = / mycode / .git --work-tree = / mycode status 

您可以阅读更多的 here

I am trying to run git from a different directory than I am in. So for example if I am in:

cd /home/domain/
git status << runs perfect ie
# On branch master
# Your branch is ahead of 'origin/master' by 6 commits.

So now I want to run this command from a different directory using the --git-dir option.

So lets say I'm in root/ and try this:

git --git-dir="/home/domain/" status
## Error 
fatal: Not a git repository: '/home/domain/'

I've also tried to include the .git folder i.e.

git --git-dir="/home/domain/.git/" status

But this looks like it's trying to run git from the root, i.e. deleting everything from my domain folder and adding everything in root.

Hope someone can advise on what I'm doing wrong.

解决方案

You have to define the working dir as well. Confusing I know but it's a flexibility thing.

git --git-dir=/mycode/.git --work-tree=/mycode status

You can read a little more here

这篇关于git --git-dir没有按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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