Skip to contentSkip to conversation

fastest way to check if dir is a workdir

DISCUSSION Thomas Koch 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi,

I'm writing a little php-git-wrapper and would like to have a function which tells me, whether a given path is part of a git checkout or not.

What would be the fastest commandline to check, whether the current dir is part of a checkout? It may be assumed that the repository is at the standard position.

Thanks a lot,

Signature · 12 lines
Thomas Koch, Software Developer
http://www.koch.ro

Young Media Concepts GmbH
Sonnenstr. 4
CH-8280 Kreuzlingen
Switzerland

Tel    +41 (0)71 / 508 24 86
Fax    +41 (0)71 / 560 53 89
Mobile +49 (0)170 / 753 89 16
Web    www.ymc.ch
#1 lore raw
Quoted 6 lines · Thomas Koch

I'm writing a little php-git-wrapper and would like to have a function which tells me, whether a given path is part of a git checkout or not.

What would be the fastest commandline to check, whether the current dir is part of a checkout? It may be assumed that the repository is at the standard position.

How about "git rev-parse --is-inside-work-tree"?

-Peff