Skip to content

Commit

Permalink
[2023-08-16]: Desktop v3.2.8 Updates (#40594)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions <[email protected]>
Co-authored-by: Isaac Brown <[email protected]>
  • Loading branch information
3 people authored Aug 16, 2023
1 parent ed8c4cd commit 2192996
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 0 deletions.
Binary file added assets/images/help/desktop/branch-item.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/help/desktop/checkout-commit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: Checking out a commit in GitHub Desktop
shortTitle: Checking out a commit
intro: 'You can use {% data variables.product.prodname_desktop %} to checkout a previous commit in your repository.'
versions:
feature: desktop
---

## About checking out a commit

Checking out a commit allows you to view your repository in a previous state without needing to create a new branch or modify an existing branch. This can be helpful when debugging since it allows you to see if a bug exists in your repository at a previous commit.

Checking out a commit puts your repository in a "detached HEAD" state. In Git terminology "HEAD" is the reference that points to the tip, or latest commit, of a named branch in your repository. A "detached HEAD" state means that HEAD refers to a specific commit, but not on a named branch in your repository.

{% note %}

**Note:** Any commits made in a "detached HEAD" state will be lost when switching branches, since these commits have not been made on a named branch. If you need to recover the lost commits, see "[Troubleshooting](#troubleshooting)."

{% endnote %}


## Checking out a commit

{% data reusables.desktop.history-tab %}
1. Right-click on the commit you would like to checkout and select **Checkout commit**.
![Screenshot of a list of commits in the "History" tab. Next to a commit, in a context menu, the "Checkout Commit" option is highlighted with an orange outline.](/assets/images/help/desktop/checkout-commit.png)
1. The {% octicon "git-branch" aria-hidden="true" %} **Current Branch** item in the repository bar will now show "Detached HEAD", along with the SHA of the commit that was checked out.
![Screenshot of the repository bar. The "Current Branch" item shows a "Detached HEAD" state and is highlighted with an orange outline.](/assets/images/help/desktop/branch-item.png)
1. To exit the "detached HEAD" state you will need to switch branches. For more information, see "[AUTOTITLE](/desktop/contributing-and-collaborating-using-github-desktop/making-changes-in-a-branch/managing-branches-in-github-desktop#switching-between-branches)."

## Troubleshooting

You can recover commits that have been made in a "detached HEAD" state using the `git reflog` command from the Git command line. You can open your repository in the command line from {% data variables.product.prodname_desktop %} by going to the menu bar, selecting **Repository**, and clicking **Open in command line**.

The `git reflog` command will show the output of events that have happened in your repository, including commits. Here is a sample output of the `git reflog` command:

```shell
81fa9136f8 (HEAD -> main) HEAD@{0}: checkout: moving from 8bd5e736a27a52a7e36a856b30e6f0582d341aa1 to main
8bd5e736a2 HEAD@{1}: commit: testing out a feature
22fa76c125 HEAD@{2}: checkout: moving from main to 22fa76c1250a2847305b9325752d941dbaa55983
```

The `8bd5e736a2 HEAD@{1}: commit: testing out a feature` line is the commit that we want to recover, since it was made while the repository was in a "detached HEAD" state. To recover it you can run `git cherry-pick 8bd5e736a2` to apply the commit to the current branch in your repository.

## Further reading

- [Detached HEAD](https://git-scm.com/docs/git-checkout#_detached_head) in the Git documentation
- [Git cherry-pick](https://git-scm.com/docs/git-cherry-pick) in the Git documentation
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ children:
- /squashing-commits-in-github-desktop
- /amending-a-commit-in-github-desktop
- /managing-tags-in-github-desktop
- /checking-out-a-commit-in-github-desktop
---

Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ shortTitle: Configure default editor
- [Emacs](https://www.gnu.org/software/emacs/)
- [Lite XL](https://lite-xl.com/)
- [Pulsar](https://pulsar-edit.dev/)
- [Zed](https://zed.dev/)

{% endmac %}

Expand Down Expand Up @@ -94,3 +95,37 @@ shortTitle: Configure default editor
1. Click **Save**.

{% endwindows %}

## Opening a repository in the default editor

To open the current repository in the default editor, you can use the menu bar:

1. In the menu bar, select **Repository**.
1. Click **Open in default editor**

If you want to open another repository in the default editor, you can use the repository list.

1. In the upper-left corner of {% data variables.product.prodname_desktop %}, to the right of the current repository name, click {% octicon "triangle-down" aria-label="The triangle-down icon" %}.
1. Right-click the repository, then click **Open in default editor**.

{% tip %}

{% mac %}

**Tip:** You can use the <kbd>Shift</kbd>+<kbd>Command</kbd>+<kbd>A</kbd> keyboard shortcut to open a repository in the default editor.

{% endmac %}

{% windows %}

**Tip:** You can use the <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>A</kbd> keyboard shortcut to open a repository in the default editor.

{% endwindows %}

{% endtip %}

## Opening a file in the default editor

1. Navigate to the "Changes" tab in the left sidebar.
2. Double-click on the file, or right-click on the file and select **Open in default editor**.

0 comments on commit 2192996

Please sign in to comment.