Finding out the name of the original repository you cloned from in Git

前端 未结 8 1088
予麋鹿
予麋鹿 2021-01-30 01:51

When you do your first clone using the syntax

git clone username@server:gitRepo.git

Is it possible using your local repository to find the name

8条回答
  •  时光取名叫无心
    2021-01-30 02:37

    This is quick Bash command, that you're probably searching for, will print only a basename of the remote repository:

    Where you fetch from:

    basename $(git remote show -n origin | grep Fetch | cut -d: -f2-)
    

    Alternatively where you push to:

    basename $(git remote show -n origin | grep Push | cut -d: -f2-)
    

    Especially the -n option makes the command much quicker.

提交回复
热议问题