I am running these two commands in Git bash.
Why they behave differently? Aren\'t they supposed to do the same thing or am I missing something?
Backslash is an escape character used to escape meta characters. This means you need to escape the escape:
D:\\Patches\\afterWGComment.txt
Alternative you can put your string in single quotes, which will make all characters literal:
'D\Patches\afterWGComment.txt'
Some meta characters: *
, ~
, $
, !
, ...