2016-10-04 166 views
0

我想創建一個bash腳本來在瀏覽器窗口中打開一個Github拉請求。在BASH腳本中獲取git repo名稱和github用戶名?

這是我需要運行命令:


開放https://github.com/ParentOwner/RepoName /比較/ 發展 ... JoshuaSoileauCurrentBranch


凡事大膽需要動態。

我需要弄清楚如何拉下面的東西在BASH:

RepoName  - name of the repo 
develop  - ARGUMENT to my bash script 
JoshuaSoileau - github username of the current user 
CurrentBranch - name of the currently checked out git branch. 

我知道如何做到以下幾點:

RepoName  - ?? 
develop  - $1 argument in my bash script 
JoshuaSoileau - ?? 
CurrentBranch - $(git rev-parse --abbrev-ref HEAD) 

我怎麼拉1. RepoName和BASH腳本中的2. Current github username

這是我到目前爲止有:

git-open-merge() { 
    open https://github.com/ParentOwner/??/compare/$1...??:$(git rev-parse --abbrev-ref HEAD) 
} 

,這就是所謂這樣的:

git-open-merge develop 

回答

0

您可以使用:

git config --get-regexp user.name 

對於用戶名 。爲庫名稱,你可能有不同的名稱不同的儲存庫,所以我想解析:

git remote get-url origin 

可以幫助,如果你只關心的由來?格式是(前綴會在ssh或https之間有所不同)[email protected]:{github_handle}/{repo_name}.git

相關問題