Sometimes in the rush of the day, it’s much easier to share code with other devs without having to create a commit, push and pull, simply because that code will not make to the repository. In this case, the patch comes at hand.
Creating the patch
git format-patch -1 <sha> ou git format-patch -1 HEAD // The -1 indicates how many commits we should include in this patch.
In this way, a file will be generated, with the .patch extension such as file.patch
git apply --stat file.patch git apply --check file.patch git am < file.patch In a nutshell, --stat shows the number of lines changed, --check checks for errors, and am effectively patchs.