Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 吉特+;grit工作目录修订信息_Ruby_Git_Grit - Fatal编程技术网

Ruby 吉特+;grit工作目录修订信息

Ruby 吉特+;grit工作目录修订信息,ruby,git,grit,Ruby,Git,Grit,我试图在我的rails应用程序页脚中显示一些git版本信息(通过grit)以进行调试。当我想看到头部时,很简单: @git_repository = Grit::Repo.new( Ter::Application.root ) head = @git_repository.heads.first t '.git_info', :revision => head.commit.id, :branch => head.name, :author => head.commit.au

我试图在我的rails应用程序页脚中显示一些git版本信息(通过grit)以进行调试。当我想看到头部时,很简单:

@git_repository = Grit::Repo.new( Ter::Application.root )
head = @git_repository.heads.first
t '.git_info', :revision => head.commit.id, :branch => head.name, :author => head.commit.author.name, :date => l(head.commit.authored_date, :format => :long)
如果我总是使用最新的版本(主标题),这是可行的。但是,我找不到一种方法来显示工作目录使用的分支或标记(grit似乎只在repo上运行,而不是工作目录)

有没有办法在grit中显示工作目录信息?

使用
grit::Repo#head
而不是
#heads
——它将为您提供与
.git/head
对应的
grit::head
对象,该对象是当前签出的提交或引用。
#heads
将为您提供所有分支。

使用
Grit::Repo#head
而不是
#heads
——它将为您提供与
.git/head
对应的
Grit::head
对象,该对象是当前签出的提交或引用。
#heads
将为您提供所有分支