sasori
sasori

Reputation: 5445

how to create one patch from different commits?

let's say, the git log in the dev server goes like this

aaaa - mine
bbbb - other dev
cccc - another dev 
dddd - mine
eeee - another dev
ffff - mine
gggg - mine

based from that example log, how to create one patch out of the 4 commits that I have ?, so that it would be easy to push my codes to staging server.

because if I do

git show gggg > first.patch
git show ffff > second.patch
git show bbbb > third.patch
git show aaaa > fourth.patch 

that's quite a lot already. Our current process is like this

1) develop 2) commit and push codes to dev server 3) once tested and verified by product owner, create patch for staging 4) apply the patches to staging 5) after QA testing verified, push to production.

so how to combine my commits to create one .patch file ?

Upvotes: 0

Views: 87

Answers (1)

Mark Adelsberger
Mark Adelsberger

Reputation: 45659

What I would do is an interactive rebase to create a branch with just your changes. The big caveat here is that you're creating a new, untested state of the code when you do this. But that's inherent in your question, so if it's really what you want to do:

My advice is to create a new branch and rebase that (leaving all existing branches as is). The new branch will represent an alternate history tailored to this push.

git checkout aaaa
git checkout -b staging_branch
git rebase --interactive gggg^

You'll get an editor with a rebase to-do list. Delete the lines for commits other than yours. If you want you can also squash the commits you keep (instead of picking all of them), but it doesn't really matter.

From there you can push staging_branch to your staging server, or if you really want the patch you can use git diff (or, if you squashed the commits, git show) to get it.

Upvotes: 2

Related Questions