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:
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
master/origin
remotes/origin/HEAD -> origin/master
remotes/origin/branch_2
remotes/origin/branch_1
Your file is already staged to be committed. You can show it's diff using the --cached option of git. To unstage it, just do what git status suggests in it's output ;) You can check The Git Index For more info.
Comparing changes with git diff Diffing is a function that takes two input data sets and outputs the changes between them. git diff is a multi-use Git command that when executed runs a diff function on Git data sources. These data sources can be commits, branches, files and more.
To exit this you can use: :q for exit; :h for help; Note: if you don't want to read the output in pager you can use an ENV variable GIT_PAGER to cat or you need to set core.
git diff --staged shows you the difference between your staging area and the last commit to the repository. git commit commits all changes in the staging area and opens Vim so you can add a commit message.
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
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