Skip to content

Commit 82cd3df

Browse files
isaacmbrowngithub-actionslecoursen
authored
Desktop: "Undoing commits" and "Options for managing commit history" (#48686)
Co-authored-by: github-actions <[email protected]> Co-authored-by: Laura Coursen <[email protected]>
1 parent 5770658 commit 82cd3df

10 files changed

+86
-3
lines changed
14.9 KB
Loading

content/desktop/making-changes-in-a-branch/committing-and-reviewing-changes-to-your-project-in-github-desktop.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ Once you're satisfied with the changes you've chosen to include in your commit,
130130

131131
![Screenshot of the "No local changes" view. A button, labeled "Preview Pull Request", is highlighted with an orange outline.](/assets/images/help/desktop/mac-preview-pull-request.png)
132132

133+
## Managing your commit history
134+
135+
If you need to undo a commit or revise your commit history (to make it easier for a reviewer to follow your changes), {% data variables.product.prodname_desktop %} provides a number of options for managing your commit history. For more information, see "[AUTOTITLE](/desktop/managing-commits/options-for-managing-commits-in-github-desktop)."
136+
133137
## Further reading
134138

135139
- "[AUTOTITLE](/get-started/using-git)"

content/desktop/managing-commits/amending-a-commit-in-github-desktop.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Amending a commit in GitHub Desktop
3-
shortTitle: Amending commits
3+
shortTitle: Amending a commit
44
intro: 'You can use {% data variables.product.prodname_desktop %} to amend your last commit.'
55
versions:
66
feature: desktop
@@ -25,3 +25,7 @@ If possible, you should only amend a commit that you haven't pushed to the remot
2525
1. In the "Changes" tab, use the **Summary** field to modify the commit message. Optionally, you can modify or add information about the commit in the **Description** field.
2626
1. Select any uncommitted changes that you would like to add to the commit. For more information about selecting changes, see "[AUTOTITLE](/desktop/making-changes-in-a-branch/committing-and-reviewing-changes-to-your-project-in-github-desktop#selecting-changes-to-include-in-a-commit)."
2727
1. Once you have finalized your changes, click **Amend last commit**.
28+
29+
## Further reading
30+
31+
- "[AUTOTITLE](/desktop/managing-commits/options-for-managing-commits-in-github-desktop)"

content/desktop/managing-commits/cherry-picking-a-commit-in-github-desktop.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Cherry-picking a commit in GitHub Desktop
3-
shortTitle: Cherry-picking
3+
shortTitle: Cherry-picking a commit
44
intro: 'You can use {% data variables.product.prodname_desktop %} to pick a specific commit on one branch and copy the commit to another branch.'
55
versions:
66
feature: desktop
@@ -46,3 +46,4 @@ You can also use cherry-picking when collaborating with a team. Some projects in
4646
## Further reading
4747

4848
- [git-cherry-pick](https://git-scm.com/docs/git-cherry-pick) in the Git documentation
49+
- "[AUTOTITLE](/desktop/managing-commits/options-for-managing-commits-in-github-desktop)"

content/desktop/managing-commits/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ intro: 'You can use {% data variables.product.prodname_desktop %} to amend, cher
44
versions:
55
feature: desktop
66
children:
7+
- /options-for-managing-commits-in-github-desktop
8+
- /undoing-a-commit-in-github-desktop
9+
- /amending-a-commit-in-github-desktop
710
- /reverting-a-commit-in-github-desktop
811
- /cherry-picking-a-commit-in-github-desktop
912
- /reordering-commits-in-github-desktop
1013
- /squashing-commits-in-github-desktop
11-
- /amending-a-commit-in-github-desktop
1214
- /managing-tags-in-github-desktop
1315
- /checking-out-a-commit-in-github-desktop
1416
redirect_from:
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: Options for managing commits in GitHub Desktop
3+
shortTitle: Options for managing commits
4+
intro: 'You can use {% data variables.product.prodname_desktop %} to maintain an easy-to-follow commit history.'
5+
versions:
6+
feature: desktop
7+
---
8+
9+
## About commit history in {% data variables.product.prodname_desktop %}
10+
11+
When you're contributing changes to a repository, your commit history should tell an easy-to-follow story about how you arrived at the changes you've made. To help people review your work, and to make it easier for people to find when and why changes were introduced to a repository, we recommend you follow certain best practices, such as:
12+
13+
- Organizing your commits into a sequential, easy-to-follow order
14+
- Writing clear commit messages that include your intent and any necessary context
15+
- Making small commits that contain related changes
16+
17+
Often, it is difficult to follow these best practices perfectly at the point where you're making changes. You might realize you need to undo the changes in a commit you've made, edit a commit message, or reorder your commits to tell a clearer story. With {% data variables.product.prodname_desktop %}, you can manage your commit history directly from the user interface.
18+
19+
{% note %}
20+
21+
**Note:** Where possible, you should avoid changing the history of commits that have already been pushed to the remote repository. Other contributors may have already based work on these commits.
22+
23+
{% endnote %}
24+
25+
## Options for managing commit history in {% data variables.product.prodname_desktop %}
26+
27+
| Option | Description | More information |
28+
| ------ | ----------- | ---------------- |
29+
| Undo a commit | Restores the changes from a commit to your working directory, so you can make further changes before re-committing. Useful if you made a mistake in the changes you included. Not possible if you have already pushed the commit to the remote repository. | "[AUTOTITLE](/desktop/managing-commits/undoing-a-commit-in-github-desktop)" |
30+
| Amend a commit | Lets you edit your most recent commit message or combine new changes with the most recent commit. Useful if the changes in the previous commit are still valid, but you have made further changes that fit into the same commit. | "[AUTOTITLE](/desktop/managing-commits/amending-a-commit-in-github-desktop)" |
31+
| Revert a commit | Creates a new commit that reverses the changes of another commit in your history. Useful if a commit has already been pushed to the remote repository, and you don't want to remove the commit from the repository's history. | "[AUTOTITLE](/desktop/managing-commits/reverting-a-commit-in-github-desktop)" |
32+
| Cherry-pick a commit | Copies a commit from one branch to another. Useful if you have accidentally committed changes on the wrong branch, or if you need to apply a bug fix across different branches you're working on. | "[AUTOTITLE](/desktop/managing-commits/cherry-picking-a-commit-in-github-desktop)" |
33+
| Reorder commits | Changes the order of commits in your history. Useful if changing the order would make your progress easier to follow. | "[AUTOTITLE](/desktop/managing-commits/reordering-commits-in-github-desktop)" |
34+
| Squash commits | Combines multiple commits into a single commit. Useful if you have a series of small commits that contain related changes. | "[AUTOTITLE](/desktop/managing-commits/squashing-commits-in-github-desktop)" |

content/desktop/managing-commits/reordering-commits-in-github-desktop.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@ When you reorder commits, you may see one of the following notifications or erro
4141
{% data reusables.desktop.resolve-merge-conflicts %}
4242

4343
1. When all conflicts are resolved, you can reorder your commits.
44+
45+
## Further reading
46+
47+
- "[AUTOTITLE](/desktop/managing-commits/options-for-managing-commits-in-github-desktop)"

content/desktop/managing-commits/reverting-a-commit-in-github-desktop.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ When you revert to a previous commit, the revert is also a commit. The original
2020

2121
{% data reusables.desktop.history-tab %}
2222
{% data reusables.desktop.revert-commit %}
23+
24+
## Further reading
25+
26+
- "[AUTOTITLE](/desktop/managing-commits/options-for-managing-commits-in-github-desktop)"

content/desktop/managing-commits/squashing-commits-in-github-desktop.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,7 @@ When you squash commits, you may see one of the following notifications or error
4444
- A notification states that the requested change to the branch will require a force push to update the remote branch. Force pushing alters the commit history of the branch and will affect other collaborators who are working in that branch. Select **Begin Squash** to start the squash, and then click **Force push origin** to push your changes.
4545
- An error states that the squash failed because there is a merge commit among the squashed commits.
4646
- A notification is shown indicating that there are uncommitted changes present on your current branch. Select **Stash Changes and Continue** to store the changes and proceed, or select **Close** to dismiss the message and commit the changes. When there are no longer any uncommitted changes you can squash your commits.
47+
48+
## Further reading
49+
50+
- "[AUTOTITLE](/desktop/managing-commits/options-for-managing-commits-in-github-desktop)"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: Undoing a commit in GitHub Desktop
3+
shortTitle: Undoing a commit
4+
intro: 'You can undo a commit before you have pushed it to the remote branch.'
5+
versions:
6+
feature: desktop
7+
---
8+
9+
## About undoing a commit
10+
11+
If you made a mistake in your changes, you can undo a commit in {% data variables.product.prodname_desktop %}. Undoing a commit restores the changes in the commit to your working directory and resets the branch to the previous commit, so you can make further changes before committing again.
12+
13+
You can undo multiple sequential commits, until you reach a commit that has already been pushed to the remote repository. To undo a pushed commit without disrupting commit history for other contributors, you can revert the commit. For more information, see "[AUTOTITLE](/desktop/managing-commits/reverting-a-commit-in-github-desktop)."
14+
15+
If you want to edit your most recent commit message, or combine new changes with your most recent commit, you can amend a commit. For more information, see "[AUTOTITLE](/desktop/managing-commits/amending-a-commit-in-github-desktop)."
16+
17+
## Undoing a commit
18+
19+
1. In the left sidebar, ensure you are on the **Changes** tab.
20+
1. At the bottom of the sidebar, click **Undo**.
21+
22+
![Screenshot of part of the "Changes" tab. Next to the commit message, a button, labeled "Undo", is highlighted with an orange outline.](/assets/images/help/desktop/undo-commit.png)
23+
24+
## Further reading
25+
26+
- "[AUTOTITLE](/desktop/managing-commits/options-for-managing-commits-in-github-desktop)"

0 commit comments

Comments
 (0)