Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't git diff work on the command line for me?

Tags:

git

diff

Every piece of documentation I've read on git (including the online book and the built-in help) says I can type "git diff" from command line, but whenever I do that I get:

usage: git diff [--no-index] <path> <path>

Here's what I've tried so far (all are examples from the documentation):

$ git diff
usage: git diff [--no-index] <path> <path>

$ git diff HEAD
usage: git diff [--no-index] <path> <path>

$ git diff --
usage: git diff [--no-index] <path> <path>

$ git diff -- .
usage: git diff [--no-index] <path> <path>

$ git diff --stat
usage: git diff [--no-index] <path> <path>

$ git --version
git version 1.7.1

Am I missing something here?

like image 218
Karl Avatar asked Jun 27 '10 16:06

Karl


People also ask

How do I use the diff command in git?

You can run the git diff HEAD command to compare the both staged and unstaged changes with your last commit. You can also run the git diff <branch_name1> <branch_name2> command to compare the changes from the first branch with changes from the second branch. Order does matter when you're comparing branches.

What is the command to check diff in git?

The git diff command is a widely used tool to track the changes. The git diff command allows us to compare different versions of branches and repository. To get the difference between branches, run the git diff command as follows: $ git diff <branch 1> < branch 2>

How do I open git diff?

Go to your repository in Git Bash. Type git config diff.

Why git add command is not working?

This is because the node_modules folder is not ignored and hence when we run git add . command git visit all your directory/files and sub directory/files which is not ignored in . gitignore hence it is taking so long time to process it as node_modules contains a large amount of files and folder.


2 Answers

Are you actually inside a directory with a Git repository when you're running these? (git rev-parse --git-dir) The command needs to be able to find the repository and determine what your working tree is in order to produce useful output. Otherwise (if a repository cannot be identified), it defaults to being a plain recursive-diff command, and needs two paths to operate.

like image 63
araqnid Avatar answered Nov 02 '22 02:11

araqnid


Are you working in a git repository? If you do a git status, do you get something close to the following?

> $ git status
> # On branch develop.new_feature
> # Changed but not updated:
> #   (use "git add <file>..." to update what will be committed)
> #
> # modified:   feature
> # modified:   www/jkll.jsp
> #
> # Untracked files:
> #   (use "git add <file>..." to include            ...
like image 26
labratmatt Avatar answered Nov 02 '22 04:11

labratmatt