Skip to content

Commit

Permalink
Merge pull request #15962 from github/repo-sync
Browse files Browse the repository at this point in the history
repo sync
  • Loading branch information
Octomerger authored Oct 9, 2020
2 parents 705869f + 0e63afc commit b575b25
Showing 1 changed file with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@ versions:

You can change the most recent commit message using the `git commit --amend` command.

{% warning %}

In Git, the text of the commit message is part of the commit. Changing the commit message will change the commit ID--i.e., the SHA1 checksum that names the commit. Effectively, you are creating a new commit that replaces the old one.

{% endwarning %}

#### Commit has not been pushed online
### Commit has not been pushed online

If the commit only exists in your local repository and has not been pushed to {% data variables.product.product_location %}, you can amend the commit message with the `git commit --amend` command.

Expand All @@ -39,7 +35,7 @@ You can change the default text editor for Git by changing the `core.editor` set

{% endtip %}

#### Amending older or multiple commit messages
### Amending older or multiple commit messages

If you have already pushed the commit to {% data variables.product.product_location %}, you will have to force push a commit with an amended message.

Expand All @@ -49,15 +45,15 @@ We strongly discourage force pushing, since this changes the history of your rep

{% endwarning %}

**Amending the message of the most recently pushed commit**
**Changing the message of the most recently pushed commit**

1. Follow the [steps above](/articles/changing-a-commit-message#commit-has-not-been-pushed-online) to amend the commit message.
2. Use the `push --force` command to force push over the old commit.
```shell
$ git push --force <em>example-branch</em>
```

**Amending the message of older or multiple commit messages**
**Changing the message of older or multiple commit messages**

If you need to amend the message for multiple commits or an older commit, you can use interactive rebase, then force push to change the commit history.

Expand Down Expand Up @@ -93,7 +89,6 @@ If you need to amend the message for multiple commits or an older commit, you ca
#
# Note that empty commits are commented out
```

3. Replace `pick` with `reword` before each commit message you want to change.
```shell
pick e499d89 Delete CNAME
Expand All @@ -102,10 +97,10 @@ If you need to amend the message for multiple commits or an older commit, you ca
```
4. Save and close the commit list file.
5. In each resulting commit file, type the new commit message, save the file, and close it.
6. Force-push the amended commits.
```shell
$ git push --force
```
6. When you're ready to push your changes to GitHub, use the push --force command to force push over the old commit.
```shell
$ git push --force <em>example-branch</em>
```
For more information on interactive rebase, see "[Interactive mode](https://git-scm.com/docs/git-rebase#_interactive_mode)" in the Git manual.
Expand Down

0 comments on commit b575b25

Please sign in to comment.