GitHub Command Palette

Use the command palette in GitHub to navigate, search, and run commands directly from your keyboard.

Note: The GitHub Command Palette is currently in public beta and is subject to change.

关于 GitHub Command Palette

You can navigate, search, and run commands on GitHub with the GitHub Command Palette. The command palette is an on-demand way to show suggestions based on your current context and resources you've used recently. You can open the command palette with a keyboard shortcut from anywhere on GitHub, which saves you time and keeps your hands on the keyboard.

Fast navigation

When you open the command palette, the suggestions are optimized to give you easy access from anywhere in a repository, user account, or organization to top-level pages like the Issues page. If the location you want isn't listed, start entering the name or number for the location to refine the suggestions.

Command palette repository suggestions

Easy access to commands

The ability to run commands directly from your keyboard, without navigating through a series of menus, may change the way you use GitHub. For example, you can switch themes with a few keystrokes, making it easy to toggle between themes as your needs change.

Command palette change theme

Opening the GitHub Command Palette

Open the command palette using one of the following keyboard shortcuts:

  • Windows and Linux: Ctrl+K or Ctrl+Alt+K
  • Mac: Command+K or Command+Option+K

When you open the command palette, it shows your location at the top left and uses it as the scope for suggestions (for example, the mashed-avocado organization).

Command palette launch

注意:

  • If you are editing Markdown text, open the command palette with Ctrl+Alt+K (Windows and Linux) or Command+Option+K (Mac).
  • If you are working on a project (beta), a project-specific command palette is displayed instead. 更多信息请参阅“自定义项目(测试版)视图”。

Navigating with the GitHub Command Palette

You can use the command palette to navigate to any page that you have access to on GitHub.

  1. Use Ctrl+K (Windows/Linux) or Command+K (Mac) to open the command palette with a scope determined by your current location in the UI.

  2. Start typing the path you want to navigate to. The suggestions in the command palette change to match your text.

    Command palette navigation current scope

  3. Optionally, narrow, expand, or completely change the scope for suggestions by editing the path in the command palette's text field.

    • To narrow the scope within a user or organization account, highlight a repository then use Tab to add it to the scope.
    • To expand the scope, highlight and remove an item in the scope using the Backspace or delete key.
    • To clear the scope and text box, click Clear or use CtrlBackspace (Windows and Linux) or Backspace (Mac).

    You can also use keystrokes to narrow your search. For more information, see "Keystroke functions."

  4. Finish entering the path, or use the arrow keys to highlight the path you want from the list of suggestions.

  5. Use Enter to jump to your chosen location. Alternatively, use Ctrl+Enter (Windows and Linux) or Command+Enter (Mac) to open the location in a new browser tab.

Searching with the GitHub Command Palette

You can use the command palette to search for anything on GitHub.com.

  1. Use Ctrl+K (Windows/Linux) or Command+K (Mac) to open the command palette with a scope determined by your current location in the UI.

  2. Optionally, narrow, expand, or completely change the scope for suggestions by editing the path in the command palette's text field.

    • To narrow the scope within a user or organization account, highlight a repository then use Tab to add it to the scope.
    • To expand the scope, highlight and remove an item in the scope using the Backspace or delete key.
    • To clear the scope and text box, click Clear or use CtrlBackspace (Windows and Linux) or Backspace (Mac).
  3. Optionally, use keystrokes to find specific types of resource:

    • # Search for issues, pull requests, discussions, and projects
    • ! Search for projects
    • @ Search for users, organizations, and repositories
    • / Search for files within a repository scope

    Command palette search files

  4. Begin entering your search terms. The command palette will offer you a range of suggested searches based on your search scope.

    You can also use the full syntax of GitHub's integrated search within the command palette. For more information, see "Searching for information on GitHub."

  5. Use the arrow keys to highlight the search result you want and use Enter to jump to your chosen location. Alternatively, use Ctrl+Enter (Windows and Linux) or Command+Enter (Mac) to open the location in a new browser tab.

Running commands from the GitHub Command Palette

You can use the GitHub Command Palette to run commands. For example, you can create a new repository or issue, or change your theme. When you run a command, the location for its action is determined by either the underlying page or the scope shown in the command palette.

  • Pull request and issue commands always run on the underlying page.
  • Higher-level commands, for example, repository commands, run in the scope shown in the command palette.

For a full list of supported commands, see "GitHub Command Palette reference."

  1. Use Ctrl+Shift+K (Windows and Linux) or Command+Shift+K (Mac) to open the command palette in command mode. If you already have the command palette open, press > to switch to command mode. GitHub suggests commands based on your location.

    Command palette command mode

  2. Optionally, narrow, expand, or completely change the scope for suggestions by editing the path in the command palette's text field.

    • To narrow the scope within a user or organization account, highlight a repository then use Tab to add it to the scope.
    • To expand the scope, highlight and remove an item in the scope using the Backspace or delete key.
    • To clear the scope and text box, click Clear or use CtrlBackspace (Windows and Linux) or Backspace (Mac).
  3. If the command you want is not displayed, check your scope then start entering the command name in the text box.

  4. Use the arrow keys to highlight the command you want and use Enter to run it.

Closing the command palette

When the command palette is active, you can use one of the following keyboard shortcuts to close the command palette:

  • Search and navigation mode: Esc or Ctrl+K (Windows and Linux) Command+K (Mac)
  • Command mode: Esc or Ctrl+Shift+K (Windows and Linux) Command+Shift+K (Mac)

GitHub Command Palette reference

Keystroke functions

These keystrokes are available when the command palette is in navigation and search modes, that is, they are not available in command mode.

KeystrokeFunction
>Enter command mode. For more information, see "Running commands from the GitHub Command Palette."
#Search for issues, pull requests, discussions, and projects. For more information, see "Searching with the GitHub Command Palette."
@Search for users, organizations, and repositories. For more information, see "Searching with the GitHub Command Palette."
/Search for files within a repository scope or repositories within an organization scope. For more information, see "Searching with the GitHub Command Palette."
!Search just for projects. For more information, see "Searching with the GitHub Command Palette."
Ctrl+C or Command+CCopy the search or navigation URL for the highlighted result to the clipboard.
EnterJump to the highlighted result or run the highlighted command.
Ctrl+Enter or Command+EnterOpen the highlighted search or navigation result in a new brower tab.
?Display help within the command palette.

Global commands

These commands are available from all scopes.

CommandBehavior
Import repositoryCreate a new repository by importing a project from another version control system. For more information, see "Importing a repository with GitHub importer."
New gistOpen a new gist. For more information, see "Creating a gist."
New organizationCreate a new organization. 更多信息请参阅“从头开始创建新组织”。
新项目Create a new project board. For more information, see "Creating a project."
New repositoryCreate a new repository from scratch. 更多信息请参阅“创建新仓库”。
Switch theme to <theme name>Change directly to a different theme for the UI. For more information, see "Managing your theme settings."

Organization commands

These commands are available only within the scope of an organization.

CommandBehavior
New teamCreate a new team in the current organization. For more information, see "Creating a team."

Repository commands

Most of these commands are available only on the home page of the repository. If a command is also available on other pages, this is noted in the behavior column.

CommandBehavior
Clone repository: <URL type>Copy the URL needed to clone the repository using GitHub CLI, HTTPS, or SSH to the clipboard. 更多信息请参阅“克隆仓库”。
New discussionCreate a new discussion in the repository. For more information, see "Creating a new discussion."
New fileCreate a new file from any page in the repository. 更多信息请参阅“添加文件到仓库”。
New issueOpen a new issue from any page in the repository. 更多信息请参阅“创建议题”。
Open in new codespaceCreate and open a codespace for this repository. 更多信息请参阅“创建代码空间”。
Open in github.dev editorOpen the current repository in the github.dev editor. For more information, see "Opening the web based editor."

File commands

These commands are available only when you open the command palette from a file in a repository.

CommandBehavior
Copy permalinkCreate a link to the file that includes the current commit SHA and copy the link to the clipboard. 更多信息请参阅“获取文件的永久链接”。
Open in github.dev editorOpen the currently displayed file in github.dev editor. For more information, see "Opening the web based editor."

Discussion commands

These commands are available only when you open the command palette from a discussion. They act on your current page and are not affected by the scope set in the command palette.

CommandBehavior
Delete discussion...Permanently delete the discussion. 更多信息请参阅“管理仓库中的讨论”。
Edit discussion bodyOpen the main body of the discussion ready for editing.
Subscribe/unsubscribeOpt in or out of notifications for additions to the discussion. 更多信息请参阅“关于通知”。
Transfer discussion...Move the discussion to a different repository. 更多信息请参阅“管理仓库中的讨论”。

Issue commands

These commands are available only when you open the command palette from an issue. They act on your current page and are not affected by the scope set in the command palette.

CommandBehavior
Close/reopen issueClose or reopen the current issue. 更多信息请参阅“关于议题”。
Convert issue to discussion...Convert the current issue into a discussion. 更多信息请参阅“主持讨论”。
Delete issue...Delete the current issue. 更多信息请参阅“删除议题”。
Edit issue bodyOpen the main body of the issue ready for editing.
Edit issue titleOpen the title of the issue ready for editing.
Lock issueLimit new comments to users with write access to the repository. 更多信息请参阅“锁定对话”。
Pin/unpin issueChange whether or not the issue is shown in the pinned issues section for the repository. 更多信息请参阅“将议题固定到仓库”。
Subscribe/unscubscribeOpt in or out of notifications for changes to this issue. 更多信息请参阅“关于通知”。
Transfer issue...Transfer the issue to another repository. 更多信息请参阅“将议题转让给其他仓库”。

Pull request commands

These commands are available only when you open the command palette from a pull request. They act on your current page and are not affected by the scope set in the command palette.

CommandBehavior
Close/reopen pull requestClose or reopen the current pull request. 更多信息请参阅“关于拉取请求”。
Convert to draft/Mark pull request as ready for reviewChange the state of the pull request to show it as ready, or not ready, for review. For more information, see "Changing the state of a pull request."
Copy current branch nameAdd the name of the head branch for the pull request to the clipboard.
Edit pull request bodyOpen the main body of the pull request ready for editing.
Edit pull request titleOpen the title of the pull request ready for editing.
Open in new codespaceCreate and open a codespace for the head branch of the pull request. 更多信息请参阅“创建代码空间”。
Subscribe/unscubscribeOpt in or out of notifications for changes to this pull request. 更多信息请参阅“关于通知”。
Update current branchUpdate the head branch of the pull request with changes from the base branch. This is available only for pull requests that target the default branch of the repository. For more information, see "About branches."

此文档对您有帮助吗?

隐私政策

帮助我们创建出色的文档!

所有 GitHub 文档都是开源的。看到错误或不清楚的内容了吗?提交拉取请求。

做出贡献

或者, 了解如何参与。