Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create git patch from two files?

I am a newbie to git and I was just wondering, if it's possible to create a git patch from two different file. There is no git repo, the scenario is that I have a file and I modified it, now I want to create a patch with the difference between these two files. Any pointers? Or should I just go ahead with creating a repo and then modifying the file and then commit the changes?

like image 655
Pensu Avatar asked Apr 01 '15 05:04

Pensu


1 Answers

Looking at the git diff man page, you can try with:

git diff --no-index --patch 

With:

git diff --no-index [--options] [--] [<path>…]

This form is to compare the given two paths on the filesystem.
You can omit the --no-index option when running the command in a working tree controlled by Git and at least one of the paths points outside the working tree, or when running the command outside a working tree controlled by Git.

Since:

  • --patch is the default option
  • You can omit the --no-index when running the command outside a working tree controlled by Git

You should be able to use git diff outside a git repo without any issue.

like image 198
VonC Avatar answered Oct 12 '22 11:10

VonC