Is there a git command that returns the current project name?

前端 未结 11 1341
终归单人心
终归单人心 2021-02-01 17:31

Does git have a built-in command for showing the name of the current remote project? Right now I\'m using this:

git remote -v | head -n1 | awk \'{print $2}\' | s         


        
11条回答
  •  南笙
    南笙 (楼主)
    2021-02-01 17:53

    Chained head awk and sed calls like this

    git remote -v | head -n1 | awk '{print $2}' | sed 's/.*\///' | sed 's/\.git//'
    

    can be combined into one sed call like this:

    git remote -v  | sed -rn '1s#.*/(.*)\.git.*#\1#p'
    

提交回复
热议问题