2

I am trying to create a patch from one directory and apply that patch to the different directory, provided both the directory contains same files.

For Example: Consider, the repo-1 /local/mnt/workspace/New_version/sample_dir/ contains File1, File2 and File3.

Consider, repo-2 /local/mnt/workspace/old_version/ contains same set of files mentioned in repo-1.

Now, I am trying to create a patch set from repo-1 and trying to apply it on the repo-2, which throws error due to path conflicts.

Is there any possible way to meet my requirement? Please help !

Ramdinesh J P
  • 139
  • 1
  • 9

1 Answers1

3

You can use -p to remove directories and --directory=<root> for this:

   -p<n>
       Remove <n> leading slashes from traditional diff paths. The default is 1.

   --directory=<root>
       Prepend <root> to all filenames. If a "-p" argument was also passed, it is applied before prepending the new root.

       For example, a patch that talks about updating a/git-gui.sh to b/git-gui.sh can be applied to the file in the working tree modules/git-gui/git-gui.sh by running git apply --directory=modules/git-gui.
mrks
  • 8,033
  • 1
  • 33
  • 62