Re: Is a given file known to git?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Christoph Duelli schrieb:
> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux