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:

  • gitignore certain file extensions in the branch
  • How do I fetch/clone only a few branches using git-svn?
  • Can one git repository track subversion and git remotes?
  • Removing libcurl3 on Linux Mint
  • What's the difference between 'git merge' and 'git rebase'?
  • I accidentally started a new git init on an existing git project, what do I need to get it back to normal?
  • 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

  • git error - failed to push some refs (pack-objects died with strange error)
  • Git: How to rollback/undo a change to an image?
  • Maintaining a multi-submodule project using git
  • Change git account in specific project
  • Github workflow: Working in multiple branches that use the same files
  • how could this git “merge commit” can have 1 parent only
  • 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.