除非我在项目目录中,否则Git不会显示日志 [英] Git won't show log unless I am in the project directory

查看:105
本文介绍了除非我在项目目录中,否则Git不会显示日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我处于不同的目录时调用 git log 。我通过 .git 的位置

  git log / Users /徕卡/ proj1 

但它表示不是git回购。如果我 cd 进入这个目录,它就可以正常工作了

  cd / Users / Leica / Proj1 
git log

这对我来说不是很清楚。 git log b

$ b $ g $ log $ [$] ; ...]


那么我做错了什么?

这就是git的工作原理。它希望从工作副本内部运行(不一定是根源)。



如果您真的必须这样做(但为什么?),您可以做

  $ git --git-dir = / Users / Leica / proj1 / .git log 

log命令的path选项是指存储库中的文件路径 (植根于存储库根,而不是你的文件系统根目录)。它将日志的输出限制为与这些文件相关的提交。


I am trying to call git log while I'm in a different directory. I pass the location where the .git is

git log /Users/Leica/proj1

but it says "not a git repo". If I cd into this directory, it works fine

cd /Users/Leica/Proj1
git log

Which is not clear to me. The git log documentation says

git log [[--] <path>…]

So what am I doing wrong?

解决方案

That's just how git works. It wants to be run from inside the working copy (does not have to be at its root).

If you really must do this (but why?), you could do

$ git --git-dir=/Users/Leica/proj1/.git log

The "path" option of the log command refers to file paths within the repository (rooted at the repository root, not your file system root). It limits the output of the log to commits relevant to those files.

这篇关于除非我在项目目录中,否则Git不会显示日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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