Patching in Git
If you made some branch by mistake, you can create a patch with the changes you made and apply it then to the appropriate branch.
So you need to create a patch file which contains changes. <N> means how many commits you’d like to grab from the current one.
git format-patch HEAD~<N>For each commit, Git is going to create a corresponding patch file.
Get daniladaniladanila’s stories in your inbox
Join Medium for free to get updates from this writer.
Then you go to the correct branch and apply these patches by doing:
git apply automaticallyGeneratedPatchName.patchIf any errors occurred, you could try to reject any conflicts. The result of this rejection is gonna be localized in new file, so you can manually see errors and fix them later.
git apply -- ignore-space-change -- ignore-whitespace --reject automaticallyGeneratedPatchName.patch





