Re: Is a given file known to git?
- From
Johannes Sixt <j.sixt@viscovery.net>
- Date
- Mar 11, 2008, 07:38 UTC
- Message-ID
- <47D636FC.2060203@viscovery.net>
- In-Reply-To
- <47D6317D.7030700@melosgmbh.de>
Christoph Duelli schrieb:
Show 8 quoted lines
> Given a repository and a path p to a file in it: > Is it possible (how?) to detect (in a bash script) if the file pointed > to by p is "known" to git? > Something along the line: > if `git knows p? > then > ... > fi
For simplicity, I'll assume with "known to git" you mean whether the current branch's tip has some content at the given path. Then you could write:
if git rev-parse HEAD:"$p" >/dev/null 2>&1 then # git knows about $p else # git does not know about $p fi
-- Hannes