0
$ git diff feature/C161920-5075-xtp-implementation-of-new-fidessa develop

fatal: ambiguous argument 'develop': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git [...] -- [...]'

the first branch is my local branch which contains my code changes; the second branch is a remote branch which will be deployed into UAT daily;

What I want is to get the diff between my local branch and develop branch and patch the file into UAT automatically.

I can get the diff from Stash portal when create one pull request, but I want to get it from command line so that I could write some scripts to get the diff files and patch them into UAT by one click.

Jason
  • 25
  • 6

3 Answers3

0
git diff feature/C161920-5075-xtp-implementation-of-new-fidessa develop --
JeffCharter
  • 1,431
  • 17
  • 27
  • lz46054@GCOTDVMMW741182 MINGW64 ~/git/server (feature/C161920-5075-xtp-implementation-of-new-fidessa) $ git diff feature/C161920-5075-xtp-implementation-of-new-fidessa develop -- fatal: bad revision 'develop' – Jason Oct 10 '18 at 05:51
  • the first branch was copied in local, the develop was not copied, can I diff my local branch with one remote branch? – Jason Oct 10 '18 at 05:58
0

If the develop you want to refer to is the name of a local branch, you can use this command to get rid of the ambiguity :

git diff feature/C161920-5075-xtp-implementation-of-new-fidessa refs/heads/develop.

Romain Warnan
  • 1,022
  • 1
  • 7
  • 13
  • thx~, only local branch could be diff? can we diff one local branch with one remote branch? what I need is compare my local code with current development branch and get what I have change in my local branch, then I can get the changes to patch into our UAT, I can get it from stash, but I want to get it from command line so I can make some code to patch my change into UAT automatically. – Jason Oct 10 '18 at 06:03
  • Yes you can diff a local branch with a remote branch: first update your local tracking branch `/` with `git fetch ` then use the diff command to make a patch : `git diff /.. > your.patch`. – Romain Warnan Oct 10 '18 at 06:11
0

This works for me.

git fetch origin;

git diff --name-only origin/develop...feature/C161920-5075-xtp-implementation-of-new-fidessa;
Dhirendra
  • 780
  • 9
  • 26
Jason
  • 25
  • 6