From 4cc5982e584031e7965216e73ad6a591bac8eb25 Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Sat, 10 Oct 2020 19:28:59 +0300 Subject: [PATCH] docs: add linkable section about updating commit messages in `CONTRIBUTING.md` (#39215) A common review request is updating the commit message of a commit. Since this is something that is not straight forward for inexperienced contributors, it is useful to be able to point a contributor to some docs outlining the process. This commit adds such a section in `CONTRIBUTING.md` (as discussed in https://github.com/angular/angular/pull/39110#discussion_r499935502). PR Close #39215 --- CONTRIBUTING.md | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dcb5013dd1..de8836e591 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -137,17 +137,37 @@ If we ask for changes via code reviews then: For more info on working with fixup commits see [here](docs/FIXUP_COMMITS.md). -> Fixup commits (as shown above) are preferred when addressing review feedback, but in some cases you may need to amend the original commit instead of creating a fixup commit (for example, if you want to update the commit message). -> To amend the last commit and update the Pull Request: -> -> ```shell -> git commit --all --amend -> git push --force-with-lease -> ``` - That's it! Thank you for your contribution! +##### Updating the commit message + +A reviewer might often suggest changes to a commit message (for example, to add more context for a change or adhere to our [commit message guidelines](#commit)). +In order to update the commit message of the last commit on your branch: + +1. Check out your branch: + + ```shell + git checkout my-fix-branch + ``` + +2. Amend the last commit and modify the commit message: + + ```shell + git commit --amend + ``` + +3. Push to your GitHub repository: + + ```shell + git push --force-with-lease + ``` + +> NOTE:
+> If you need to update the commit message of an earlier commit, you can use `git rebase` in interactive mode. +> See the [git docs](https://git-scm.com/docs/git-rebase#_interactive_mode) for more details. + + #### After your pull request is merged After your pull request is merged, you can safely delete your branch and pull the changes from the main (upstream) repository: