git diff gives ambigious argument error

I recently moved from SVN to git, and trying to learn my way around git.
I need to find the files that have changed between 2 branches of my repository. I use the following command to that:

git diff branch_2..branch_1

I get the follwing error:

  • Is Unfuddle reliable?
  • Show all commits whose diff contain specific string
  • How to view remote Git revision on Heroku
  • How do I get the ID of the last push in git?
  • Merging changes in intermediate branches with DVCS
  • Can I push the definition of a remote itself to a remote?
  • fatal: ambiguous argument 'branch_2..branch_1': unknown revision or path not in the working tree.
    Use '--' to separate paths from revisions, like this:
    'git <command> [<revision>...] -- [<file>...]'

    git branch gives the following o/p:

    git branch -a
    * branch_1
    remotes/origin/HEAD -> origin/master

  • How to close a GitHub pull request with a commit message?
  • Using Git and Dropbox together effectively?
  • git-svn fails to commit back to svn repo despite clean rebase
  • accidentally committed in git
  • How do you specify git URLs with spaces on Windows under cygwin?
  • Git: committing a symlink to a folder
  • One Solution collect form web for “git diff gives ambigious argument error”

    If you are simply doing:

    git diff branch2..branch1

    This will not work, as listed in your git branch list, your ‘remotes’ are specified as “origin”. What this actually means is that you have those branches on your remote, but they aren’t actually checked out locally.

    So you have two options here. Try these, and let me know how it goes.

    Based on the branch list provided:

    Diff using origin/

    git diff origin/branch2..branch1

    If you want to checkout these branches locally to perform your diff and maybe work on them on your workstation. Furthermore, supporting the diff in this format:

    git diff branch2..branch1

    What you need to do is actually checkout those branches to set them as local branches from your remote. Simply do this:

    git checkout branch2

    Then you can do

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