How to change the git directory delimiter?

When working inside a windows command prompt, all of my paths indicate director separators with a backslash , when using GIT commands, all of the paths are instead using forwardslash / . How do I change GIT's output to mirror my command line output?

Example inconsistent directory indicators;

D:gitdemo>git status --s
A  test/subdir/foo.txt

How do I change GIT's output to mirror my command line output?

First, all git commands are executed in a git bash sub-shell, which explains why you see ' / '. A ' ' is an escape character for a bash session, which is why it is not used in any bash command output.

You would need to use a git wrapper (a git.pat set in your PATH) in order to replace any / by .

git.bat :

C:prgsgitlatestbingit.exe %*|C:prgsgitlatestusrbinsed.exe -e 's:/:\:'

Make sure git.bat is set before git.exe in your %PATH% : type where git to check the order in which git(s) are discovered.
And replace C:prgsgitlatest by the path your Git is installed.

By specifying the full path for git.exe and for sed.exe , you are sure to use the right executable.


Since what you're looking for seems to be not specifically "how do I make Git use in file paths" but rather "how do I make Git generate file paths with ", you can pipe the output through sed (which is packaged in Git Bash) like so:

$ git status --s | sed 's////g'
 M dirfile.py
?? dirinput001.txt
?? diroutput001.txt

and to avoid typing sed every single time you can configure a Git alias to do it for you:

[alias]
    ws = "!ws() { : git status ; git status --short $@ | sed 's///\/g' ; } && ws"

which will let you do this:

$ git ws
 M dirfile.py
?? dirinput001.txt
?? diroutput001.txt
链接地址: http://www.djcxy.com/p/94698.html

上一篇: 没有Firebase的Android推送通知

下一篇: 如何更改git目录分隔符?