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?
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:
--no-index
when running the command outside a working tree controlled by GitYou should be able to use git diff
outside a git repo without any issue.
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