You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/github/committing-changes-to-your-project/changing-a-commit-message.md
+8-13Lines changed: 8 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,13 +13,9 @@ versions:
13
13
14
14
You can change the most recent commit message using the `git commit --amend` command.
15
15
16
-
{% warning %}
17
-
18
16
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.
19
17
20
-
{% endwarning %}
21
-
22
-
#### Commit has not been pushed online
18
+
### Commit has not been pushed online
23
19
24
20
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.
25
21
@@ -39,7 +35,7 @@ You can change the default text editor for Git by changing the `core.editor` set
39
35
40
36
{% endtip %}
41
37
42
-
####Amending older or multiple commit messages
38
+
### Amending older or multiple commit messages
43
39
44
40
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.
45
41
@@ -49,15 +45,15 @@ We strongly discourage force pushing, since this changes the history of your rep
49
45
50
46
{% endwarning %}
51
47
52
-
**Amending the message of the most recently pushed commit**
48
+
**Changing the message of the most recently pushed commit**
53
49
54
50
1. Follow the [steps above](/articles/changing-a-commit-message#commit-has-not-been-pushed-online) to amend the commit message.
55
51
2. Use the `push --force` command to force push over the old commit.
56
52
```shell
57
53
$ git push --force <em>example-branch</em>
58
54
```
59
55
60
-
**Amending the message of older or multiple commit messages**
56
+
**Changing the message of older or multiple commit messages**
61
57
62
58
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.
63
59
@@ -93,7 +89,6 @@ If you need to amend the message for multiple commits or an older commit, you ca
93
89
#
94
90
# Note that empty commits are commented out
95
91
```
96
-
97
92
3. Replace `pick` with `reword` before each commit message you want to change.
98
93
```shell
99
94
pick e499d89 Delete CNAME
@@ -102,10 +97,10 @@ If you need to amend the message for multiple commits or an older commit, you ca
102
97
```
103
98
4. Save and close the commit list file.
104
99
5. In each resulting commit file, type the new commit message, save the file, and close it.
105
-
6. Force-push the amended commits.
106
-
```shell
107
-
$ git push --force
108
-
```
100
+
6. When you're ready to push your changes to GitHub, use the push --force command to force push over the old commit.
101
+
```shell
102
+
$ git push --force <em>example-branch</em>
103
+
```
109
104
110
105
For more information on interactive rebase, see "[Interactive mode](https://git-scm.com/docs/git-rebase#_interactive_mode)" in the Git manual.
0 commit comments