如何获取当前仓库的名称和 person/org 以便在 .gitconfig 中使用?
How to get the name and person/org of the current repo for use in .gitconfig?
基本上我想做的是有一个方便的工具,我可以说:
git open
这只会在您的浏览器中打开当前的 github 存储库。如果我能得到名字,我可以使用 https://github.com/{user or org}/{repo name}
.
的别名
试试这个 bash 函数
对于Linux:
function git-open-url(){
xdg-open `git config --get remote.origin.url`
}
对于Mac:
function git-open-url(){
open `git config --get remote.origin.url`
}
我见过 git-open 工具。这很酷,但我只是想在我的 .gitconfig
中添加一些内容,所以这就是我最终所做的。
[alias]
open = "!open https://github.com/$(echo $(git remote get-url origin) | cut -f2 -d\":\")"
完美运行:)
基本上我想做的是有一个方便的工具,我可以说:
git open
这只会在您的浏览器中打开当前的 github 存储库。如果我能得到名字,我可以使用 https://github.com/{user or org}/{repo name}
.
试试这个 bash 函数
对于Linux:
function git-open-url(){
xdg-open `git config --get remote.origin.url`
}
对于Mac:
function git-open-url(){
open `git config --get remote.origin.url`
}
我见过 git-open 工具。这很酷,但我只是想在我的 .gitconfig
中添加一些内容,所以这就是我最终所做的。
[alias]
open = "!open https://github.com/$(echo $(git remote get-url origin) | cut -f2 -d\":\")"
完美运行:)