Creating a patch
Let's explain what a patch is with an example. An external programmer was called by Jim to make small fixes in a part of the project, but Jim didn't want to give him access to the repository, thus preventing him from pushing data. So, he decides to make a patch and sends it by e-mail to Jim:
External@local:~/webproject$ git format-patch origin patch-webproject.patch
This command will create .patch
files per commit and the external programmer will send the e-mail with it. So, he decides to make a patch and send it by e-mail to Jim.
Jim can import the patch by executing this:
Jim@local:~/webproject$ git apply /tmp/patch-webproject.patch
This command will apply the patch, but it doesn't create commits.
So, to generate a series of commits, use the git am
command:
Jim@local:~/webproject$ git am /tmp/patch-webproject.patch