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

前端 未结 4 1403
庸人自扰
庸人自扰 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:31

    Any directory in the system could be a git working copy. You can use an directory as if it contained a .git subdirectory by setting the GIT_DIR and GIT_WORK_TREE environment variables to point at an actual .git directory and the root of your working copy, or use the --git-dir and --work-tree options instead. See the git man page for more details.

提交回复
热议问题