I want to move two files from one repository to another. The files were originally added as:
/src/init/Price.cs
/tests/init/PriceTests.cs
The two files were later renamed to:
/src/init/PriceValue.cs
/tests/init/PriceValueTests.cs
And then moved to:
/src/moved/PriceValue.cs
/tests/moved/PriceValueTests.cs
I've tried to go by this description to create a set of patches for these files, but I'm unsure how to pass in the six different paths the files have existed on.
I've managed to find all the commit IDs affecting PriceValue.cs
(across renames and moves), but passing those IDs to Git fails with the following error message:
$ git format-patch -o /tmp/pricevaluepatches $(git log --all dfeeb 6966b 9f882 …)
-bash: /usr/local/bin/git: Argument list too long
So, how do I create a set of patches for this that only contains the changes to the mentioned files, but contains it across one rename and one move of each file?
In order to create Git patch file for a specific commit, use the “git format-patch” command with the “-1” option and the commit SHA. In order to get the commit SHA, you have to use the “git log” command and look for the corresponding commit SHA.
You click on Actions->Create Patch... You click on "Working Copy Changes" You can now select all files that should be included into the patch file.
To create a patch file from one commit to other i.e a patch file in which changes include all the commits from starting commit and end commit. It is done by git diff starting-commit-sha ending-commit-sha myPatch. patch, where “myPatch” is the patch name and the starting and ending sha of the commits are included.
You can get the patches of a few specific files but not earlier than commit sha1
using
git format-patch sha1 -- file1 file2 ...
Any of the files can be an old file (prior to a rename) or an existing file.
If you want all commits until commit sha1
you can use
git format-patch --root sha1 -- file1 file2 ...
So in your case, all commits until now (HEAD
) of your six files:
git format-patch --root HEAD -- /src/init/Price.cs /src/init/PriceValue.cs /src/moved/PriceValue.cs /src/init/PriceTests.cs /src/init/PriceValueTests.cs /src/moved/PriceValueTests.cs
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