Yesterday I have added several features to a fork of semantic-release-gitlab. I have opened a pull request (called "Merge Request" on GitLab) to the repo's author here. The pull request has 6 commits, since I was adding more code as I was debugging the problem. The author Hutson Betts asked me to split my pull request into 3 smaller focused ones.
@bahmutov would you mind breaking your merge request into three parts:
This is a valid request. Let me show how to do this step by step.
I have my own local fork of the repo, and I have been adding my commits
master branch. The one line Git log looks like this
$ git log --oneline --graph --all --decorate
The bottom commit
2.2.3 is the last common commit before I
started adding my own code in
debug feature has been
implemented in two commits
* 1643993 updated debugging comment in readme
Let us create a separate branch from the common commit
50dc59a and pick
these two commits.
$ git checkout 50dc59a
The cherry picked commits have brand new ids, they are no longer
We now have branch
debug-messages with just two commits related to debug
messages. While we are here, we can tidy the code up a little. For example,
I have changed the debug trigger to be the full
module name instead of short but fuzzy
release. This created new commit
17b67e1 chore(debug): using semantic-release-gitlab as debug log label.
It is a good practice to squash multiple commits into one before making a
pull request. We have 3 commits we want to squash into one. Run the
git rebase -i HEAD~3 which opens your text editor. By default
the three commits are shown as
pick which means they will be kept
separately. Edit the lines to have one
pick and two
pick d29e22c feat(debug): added debug module for extra messages when needed
Save the file end exit. It will open a second editor session where you can edit the commit message for the newly created single commit. I just kept the message from the very first commit, saved and exited.
[detached HEAD 761215d] feat(debug): added debug module for extra messages when needed
debug-messages now has a single commit I can push to the remote
$ git push origin debug-messages
At GitLab.com create a new merge request and this time use the branch
From bahmutov/semantic-release-gitlab:debug-messages into hutson/semantic-release-gitlab:master
You can see this request online.
I can repeat the process and create new cherry picked branches with the other two features.
To actually remove commits from the
master branch see the instructions
in this blog post.
In a nut shell:
- Reset local HEAD position to the last "good" commit
git reset <id> --hard
- Force push the master branch to the origin
git push origin +master
Standard warnings apply :)