This command works fine:
git diff relative/path/to/file.ext
But if I use the full path, git says that path "is outside repository":
git diff /full/path/then/relative/path/to/file.ext
I suppose git does not find a .git directory in /full, so that's why it fails.
But how do I make git understand full paths, like subversion does?
Update: git version 1.7.0.5
Update: These files are always inside my repository, and my current directory is also inside my repository! It still gives that error.
A full path is also referred to as the file path or the absolute path and refers to the location of your web site files on the server, relative to the server's file system structure.
Porcelain Format Version 1 Version 1 porcelain format is similar to the short format, but is guaranteed not to change in a backwards-incompatible way between Git versions or based on user configuration. This makes it ideal for parsing by scripts.
The git add command adds a change in the working directory to the staging area. It tells Git that you want to include updates to a particular file in the next commit.
Which version of git are you using? It should work regardless of the format of the path, i.e.
cd git
git diff -- git.c
git diff -- ~/git/git.c
But you have to be inside the git repository for this to work! If you absolutely need the git command to be executed from outside the repository, use the --work-tree
and --git-dir
switches:
git --work-tree=~/git --git-dir=~/git/.git diff -- git.c
git --work-tree=~/git --git-dir=~/git/.git diff -- ~/git/git.c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With