git add patch on file with parentheses in the file path

I want to run git add -p on a file with a full path that includes parentheses, like so:

git add -p "(External)/Project/Filename.cs"

However, when I run this, I get the following error:

  • Git Status: fatal: index file open failed: Invalid argument within cmd.exe
  • Why git can't remember my passphrase under Windows
  • Git Command Does not Work in Windows CMD
  • git help in Windows command prompt
  • TortoiseSVN command keeps open processes
  • Git Windows Command Prompt gets stuck during Git commands with (END)
  • sh: -c: line 0: syntax error near unexpected token `('
    sh: -c: line 0: `git ls-files -- (External)/Project/Filename.cs'
    

    I have also tried escaping the parentheses using \, but I get the same error. For comparison, a regular git add has no issues with the parentheses.

    How can I pass in this file to git add -p?

    EDIT: It seems relevant that I’m using Windows.

  • Git submodules: Is it possible to notify other developers of a change?
  • What's the Git way to work with C++ projects that share the same code at different revisions?
  • How to make sure what I commit does not contain whitespace error
  • working with two repositories in one root folder in git?
  • Can't user Composer to install own git repository
  • assertion failed errors when trying to git subtree split
  • One Solution collect form web for “git add patch on file with parentheses in the file path”

    You are most likely having a problem with your shell wrongly escaping your parenthesis.

    Using the following, worked for me (no need for quotes, only escaping the parenthesis with backslash):

    git add -p \(External\)/Project/Filename.cs
    

    in order to do the escaping right, I find it very helpful to use the auto-completion capabilities of bash, something like the following helps constructing the filename in a “bash-safe” way.

    git add -p \(E[tab]...
    

    if this doesn’t help, you could simply try to first cd into “(External)/Project” and then use

    git add -p Filename.cs
    

    UPDATE

    if you are using W32 (which is obviously the case), then i can confirm the problem.
    the only workaround i found so far is to use git gui, which is simply a nice front-end to git add -p and which seems to work, even with parentheses.

    Git Baby is a git and github fan, let's start git clone.