In git, if we want to exclude a file from diff output (on bash) we do something like follows:
git diff -- !(file.txt)
But this is disallowed in powershell. Hence is there a way to achieve this in the powershell prompt?
Simply single-quote your argument:
git diff -- '!(file.txt)'
Single-quoting makes PowerShell treat the string literally and prevents it from interpreting chars. such as (
as its own metacharacters.
Before invoking the target program, PowerShell re-quotes arguments if and as needed , behind the scenes; that is:
It encloses an argument in "..."
if it contains whitespace, and also in certain, less common scenarios (see link below).
It passes it without quotes otherwise.
Note: There are pitfalls associated with this invisible re-quoting - see this answer .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.