1
0
mirror of synced 2025-12-19 18:10:59 -05:00

Desktop: "Undoing commits" and "Options for managing commit history" (#48686)

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Laura Coursen <lecoursen@github.com>
This commit is contained in:
Isaac Brown
2024-01-17 12:49:09 +00:00
committed by GitHub
parent 5770658b22
commit 82cd3df9ff
10 changed files with 86 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -130,6 +130,10 @@ Once you're satisfied with the changes you've chosen to include in your commit,
![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) ![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)
## Managing your commit history
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)."
## Further reading ## Further reading
- "[AUTOTITLE](/get-started/using-git)" - "[AUTOTITLE](/get-started/using-git)"

View File

@@ -1,6 +1,6 @@
--- ---
title: Amending a commit in GitHub Desktop title: Amending a commit in GitHub Desktop
shortTitle: Amending commits shortTitle: Amending a commit
intro: 'You can use {% data variables.product.prodname_desktop %} to amend your last commit.' intro: 'You can use {% data variables.product.prodname_desktop %} to amend your last commit.'
versions: versions:
feature: desktop feature: desktop
@@ -25,3 +25,7 @@ If possible, you should only amend a commit that you haven't pushed to the remot
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. 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.
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)." 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)."
1. Once you have finalized your changes, click **Amend last commit**. 1. Once you have finalized your changes, click **Amend last commit**.
## Further reading
- "[AUTOTITLE](/desktop/managing-commits/options-for-managing-commits-in-github-desktop)"

View File

@@ -1,6 +1,6 @@
--- ---
title: Cherry-picking a commit in GitHub Desktop title: Cherry-picking a commit in GitHub Desktop
shortTitle: Cherry-picking shortTitle: Cherry-picking a commit
intro: 'You can use {% data variables.product.prodname_desktop %} to pick a specific commit on one branch and copy the commit to another branch.' intro: 'You can use {% data variables.product.prodname_desktop %} to pick a specific commit on one branch and copy the commit to another branch.'
versions: versions:
feature: desktop feature: desktop
@@ -46,3 +46,4 @@ You can also use cherry-picking when collaborating with a team. Some projects in
## Further reading ## Further reading
- [git-cherry-pick](https://git-scm.com/docs/git-cherry-pick) in the Git documentation - [git-cherry-pick](https://git-scm.com/docs/git-cherry-pick) in the Git documentation
- "[AUTOTITLE](/desktop/managing-commits/options-for-managing-commits-in-github-desktop)"

View File

@@ -4,11 +4,13 @@ intro: 'You can use {% data variables.product.prodname_desktop %} to amend, cher
versions: versions:
feature: desktop feature: desktop
children: children:
- /options-for-managing-commits-in-github-desktop
- /undoing-a-commit-in-github-desktop
- /amending-a-commit-in-github-desktop
- /reverting-a-commit-in-github-desktop - /reverting-a-commit-in-github-desktop
- /cherry-picking-a-commit-in-github-desktop - /cherry-picking-a-commit-in-github-desktop
- /reordering-commits-in-github-desktop - /reordering-commits-in-github-desktop
- /squashing-commits-in-github-desktop - /squashing-commits-in-github-desktop
- /amending-a-commit-in-github-desktop
- /managing-tags-in-github-desktop - /managing-tags-in-github-desktop
- /checking-out-a-commit-in-github-desktop - /checking-out-a-commit-in-github-desktop
redirect_from: redirect_from:

View File

@@ -0,0 +1,34 @@
---
title: Options for managing commits in GitHub Desktop
shortTitle: Options for managing commits
intro: 'You can use {% data variables.product.prodname_desktop %} to maintain an easy-to-follow commit history.'
versions:
feature: desktop
---
## About commit history in {% data variables.product.prodname_desktop %}
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:
- Organizing your commits into a sequential, easy-to-follow order
- Writing clear commit messages that include your intent and any necessary context
- Making small commits that contain related changes
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.
{% note %}
**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.
{% endnote %}
## Options for managing commit history in {% data variables.product.prodname_desktop %}
| Option | Description | More information |
| ------ | ----------- | ---------------- |
| 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)" |
| 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)" |
| 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)" |
| 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)" |
| 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)" |
| 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)" |

View File

@@ -41,3 +41,7 @@ When you reorder commits, you may see one of the following notifications or erro
{% data reusables.desktop.resolve-merge-conflicts %} {% data reusables.desktop.resolve-merge-conflicts %}
1. When all conflicts are resolved, you can reorder your commits. 1. When all conflicts are resolved, you can reorder your commits.
## Further reading
- "[AUTOTITLE](/desktop/managing-commits/options-for-managing-commits-in-github-desktop)"

View File

@@ -20,3 +20,7 @@ When you revert to a previous commit, the revert is also a commit. The original
{% data reusables.desktop.history-tab %} {% data reusables.desktop.history-tab %}
{% data reusables.desktop.revert-commit %} {% data reusables.desktop.revert-commit %}
## Further reading
- "[AUTOTITLE](/desktop/managing-commits/options-for-managing-commits-in-github-desktop)"

View File

@@ -44,3 +44,7 @@ When you squash commits, you may see one of the following notifications or error
- 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. - 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.
- An error states that the squash failed because there is a merge commit among the squashed commits. - An error states that the squash failed because there is a merge commit among the squashed commits.
- 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. - 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.
## Further reading
- "[AUTOTITLE](/desktop/managing-commits/options-for-managing-commits-in-github-desktop)"

View File

@@ -0,0 +1,26 @@
---
title: Undoing a commit in GitHub Desktop
shortTitle: Undoing a commit
intro: 'You can undo a commit before you have pushed it to the remote branch.'
versions:
feature: desktop
---
## About undoing a commit
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.
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)."
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)."
## Undoing a commit
1. In the left sidebar, ensure you are on the **Changes** tab.
1. At the bottom of the sidebar, click **Undo**.
![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)
## Further reading
- "[AUTOTITLE](/desktop/managing-commits/options-for-managing-commits-in-github-desktop)"