About commit history in GitHub 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 GitHub Desktop, you can manage your commit history directly from the user interface.
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.
Options for managing commit history in GitHub 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. | Undoing a commit in GitHub Desktop |
Reset to commit | Similar to undoing a commit, but restores the changes from all of the commits up to the selected commit to your working directory. Can only be used up to the most recent commit that has been pushed to the remote repository. | Resetting to 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. | 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. | 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. | 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. | 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. | Squashing commits in GitHub Desktop |