git diff 4ee42367 8c650199 > changes2.patch
git checkout newBranch
git apply changes2.patch
error: unrecognized input
When i tried to apply the changes i'll get the error. What i'm doing wrong?
I figured out this problem as instructed below,
git checkout -b new_branch
and commit somethinggit diff master --no-color > your_patch_file.patch
git checkout master
git apply your_patch_file_name.patch
Or you can run your git commands on Git Bash, probably you won't encounter any problem.
In case anyone else has this issue: for me, Powershell was the culprit. using Anentropic's answer from within git bash resulted in a "good" (readable) patch.
For those running this form within Powershell, here is another post with information about the encoding error, and why it is happening.
If you're just looking for an answer, you can edit your powershell profile:
PS> code $profile
and add
$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'
This can cause other issues, so use at your own risk.
If you just want to run it for a single instance, you can do this
$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'
git diff > change.patch
git checkout otherbranch
git apply change.patch
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