0

I have an untracked file with some changes. Its called file1.

I want to apply those changes to my tracked file in git, called file2.

Is there a way using git that I can get the patch and apply it to my tracked file , file2?

Ankur Agarwal
  • 23,692
  • 41
  • 137
  • 208
  • Correct me if I'm wrong, but: you have a file that's untracked locally, and it has changes that you want to incorporate into your tracked file locally, right? Why not use `git add ` instead? Why do you want to create a patch file? – Makoto Jun 01 '15 at 20:36
  • @makoto I just edited my question to make it more clear. – Ankur Agarwal Jun 01 '15 at 20:51
  • possible duplicate of [Create a git patch from the changes in the current working directory](http://stackoverflow.com/questions/5159185/create-a-git-patch-from-the-changes-in-the-current-working-directory) – Makoto Jun 01 '15 at 20:53

1 Answers1

0

By definition, if your files are untracked, Git does not know about their history. You can use git diff to get the difference between two files, and git apply to apply a patch, but this all makes sense only once you have two states (before changes, after changes).

Matthieu Moy
  • 15,151
  • 5
  • 38
  • 65