Check if directory is git repository (without having to cd into it)

前端 未结 4 1345
庸人自扰
庸人自扰 2021-02-18 12:51

What\'s a shell command I can use to, using the full directory path, determine whether or not a given directory is a git repository? Specifically, I\'d like to be able to do thi

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-18 13:37

    Adding to @Walk's comments, git status will throw fatal message if its not a repo. echo $? will help to capture of its an ERROR or not. If its a git repo then echo $? will be 0 else 128 will be the value

提交回复
热议问题