My git commits are a bit messed up and I was wondering if I could squash them all together and then “extract” some commits from that commit.
Let’s say I have these files in one commit:
upload.py,
moderate.py,
upload.html,
moderaion.html
How can I split it in two commits like this?
upload:
upload.py,
upload.html
moderation:
moderate.py,
moderaion.html
You question implies that the commits are already messy, but if the commits themselves are ‘atomic’ but just in the wrong order, you can also use git rebase –interactive to put them in the right order and then squash them. This might make things more easy for you.
If the commits already touch several areas and you want to split them up, again, git rebase -i can help. Also have a look at the example at Bart’s blog.