This is an old revision of the document!
creating a patch file
If you are not the maintainer for a project, but still want to contribute, you can clone the repo and modify files. You might fix a bug or add a feature. Then you can email a “patch” file containing your changes to the actual maintainer of the project. You might try to work on a specific bug or feature ticket.
git format-patch master --stdout > your-patch-file.diff
applying a patch file
First create a new branch:
git checkout -b new-branch-name
Then apply the patch:
git am < their-patch-file.diff
manually rewriting data for a project
- :
: this will change your SHA-1's, so don't do it if you care about those who track your project
- create a patch file for the entire project
git format-patch --root --stdout > allcommits.patch
- create a new project folder, and copy the patch file into it
mkdir newproject cd newproject cp ../oldproject/allcommits.patch .
- edit the allcommits.patch file as necessary (change dates, commit messages, author, etc…)
- to help with figuring out the correct date string used in patch files, you can use the unix date command to convert (you can add the time with similar parameters, but it is easy enough to type it by hand):
date -v2m -v4d -v2008y +"%a, %d %b %Y %H:%M:%S %z"
- apply all patches
git am < allcommits.patch
- also consider if filter-branch is a better alternative for your situation