I did some search online. I know that you can use format-patch after commit, but my situation is a little different.
I want to create a patch, similar to "dpk" in SVN, so I can send it out for code review, but I don't yet want to commit it.
How can I achieve this with Git?
To create a Git patch file, you have to use the “git format-patch” command, specify the branch and the target directory where you want your patches to be stored.
GIT patch or GIT diff is used to share the changes made by you to others without pushing it to main branch of the repository. This way other people can check your changes from the GIT patch file you made and suggest the necessary corrections.
When other guys had already given some answer which comply with git convention, the OP's question, "create a patch without commit", can be also solved in this way:
git diff > my_patch.txt
Later you can apply this patch, also without a commit, by:
git apply my_patch.txt
But if you are just working locally, a git checkout another_branch -m
is good enough to bring all your current uncommit changes to that another_branch, without even patch and apply.
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