Re: Command whose exit code indicates clean or dirty working directory

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

 



On 2025-04-10 at 17:49:23, Ross Goldberg wrote:
> What is the simplest git command that returns 0 if the working directory is completely clean, or nonzero if it is dirty in any way (staged diff, unstaged diff, file that is both untracked & not ignored, etc.), with nothing printed to stdout or to stderr?
> If the simplest such command is complex, is there any feature request to create a simple command, possibly with options that specify what is considered dirty (staged diffs, unstaged diffs, untracked & not ignored, etc.)?

Here's what I've used:

[ -z "$(git status --porcelain)" ]

That assumes you know the directory is a non-bare working tree.

`git status --porcelain` prints nothing if the working directory is
clean and prints what's dirty otherwise.
-- 
brian m. carlson (they/them)
Toronto, Ontario, CA

Attachment: signature.asc
Description: PGP signature


[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