- Set up the branches
git checkout master
git branch MAXT-F
git checkout -b MAXT-B
- Do some coding on MAXT-B, then commit it
git commit -a
- Type in commit message that looks something like this:
MAXT-B: Dummy commit backend
<url to JIRA>
Did you know that if you format your commit message like this,
GitHub will automatically pull it in as your PR description?
git checkout MAXT-F
- As is often the case, my frontend feature depends on the backend code
git merge MAXT-B
- Do some coding on MAXT-F, then commit it
git commit -a
- Type in another commit message
MAXT-F: Dummy commit frontend
<url to JIRA>
Description of the decisions, functionality, and gotchas that
have popped up in this branch
- Next you do a rebase
git rebase -i origin/master
- I'm presented with something that looks like this:
1 pick edad2c7 Dummy commit backend
2 pick d47817f Dummy commit frontend
3
4 # Rebase ef3e4f7..d47817f onto ef3e4f7 (2 command(s))
5 #
6 # Commands:
7 # p, pick = use commit
8 # r, reword = use commit, but edit the commit message
9 # e, edit = use commit, but stop for amending
10 # s, squash = use commit, but meld into previous commit
11 # f, fixup = like "squash", but discard this commit's log message
12 # x, exec = run command (the rest of the line) using shell
13 #
14 # These lines can be re-ordered; they are executed from top to bottom.
15 #
16 # If you remove a line here THAT COMMIT WILL BE LOST.
17 #
18 # However, if you remove everything, the rebase will be aborted.
19 #
20 # Note that empty commits are commented out
- I've annotated the lines with numbers for your viewing pleasure.
- Notice line 16? It says that "If you remove a line here THAT COMMIT WILL BE LOST."
- Notice the 1st line with the commit SHA edad2c7? If you delete it, the commit that merged MAXT-B is removed from your history.
- As a result, you will only have the code that is relevant to your frontend ticket in that branch.
- You can make a PR for each branch and all the cross-merging issues are avoided. :grin: