Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a patch without commit in Git

Tags:

git

patch

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?

like image 742
doglin Avatar asked Mar 21 '12 18:03

doglin


People also ask

How do I create a patch in 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.

What is git patch command?

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.


Video Answer


1 Answers

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.

like image 101
RayLuo Avatar answered Sep 20 '22 10:09

RayLuo