开发者

Getting the description of a Git repository

开发者 https://www.devze.com 2023-03-20 12:58 出处:网络
I\'m trying to find a way to store and retrieve the description of a bare Git repository. For normal repositories, I use a README file where I can leave a description of the project. But this does no

I'm trying to find a way to store and retrieve the description of a bare Git repository.

For normal repositories, I use a README file where I can leave a description of the project. But this does not exist in a bare repository.

I'm using the description file in the bare re开发者_开发问答pository at the moment. But I wanted to know if there was a git command to read and/or set the contents of this file without having to open/edit the file directly.


No, description file is self-contained, so there's no need to provide git commands to edit/view it. Just use it as a normal file.


Note: as an alternative, you can consider git notes: a note can be put, updated or removed even in a bare repo!

VonC@NETVONC /c/Prog/git/t/gitolite.git (BARE:pu)
$ git notes --ref descr add -m "a description" initcommit

VonC@NETVONC /c/Prog/git/t/gitolite.git (BARE:pu)
$ git notes --ref descr show initcommit
a description

What I like to do is to tag the first commit with a tag nammed "initcommit", that way I can easily get back a note in a given namespace (here 'descr'), if that note isn't supposed to have information about a "current" commit, but rather information valid for the all repo.
So I attach said note to a "fixed" commit I know I can always refer to (here the first commit, with its dedicated tag).


I first convert the URL of the repo. I want to query to https (in case it's a ssh URL) :

alias gitHTTP_URL='\git config remote.origin.url | \sed -E "s|^git@|https://|;s|(\.\w+):|\1/|"'

Then I type this (the pup tool is needed) to fetch the page title with the cURL standard tool :

echo $(\curl -qs $(gitHTTP_URL) | pup --charset utf8 "title text{}" | cut -d: -f2-)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号