These are the changes in the pre-review version of PR: https://github.com/github/docs-internal/pull/29794 This version of the Codespaces docs forms the base for the Universe megabranch.
5.0 KiB
title, intro, product, versions, type, topics, shortTitle
| title | intro | product | versions | type | topics | shortTitle | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Using source control in your codespace | After making changes to a file in your codespace you can quickly commit the changes and push your update to the remote repository. | {% data reusables.gated-features.codespaces %} |
|
how_to |
|
Source control |
About source control in {% data variables.product.prodname_github_codespaces %}
You can perform all the Git actions you need directly within your codespace. For example, you can fetch changes from the remote repository, switch branches, create a new branch, commit and push changes, and create a pull request. You can use the integrated terminal within your codespace to enter Git commands, or you can click icons and menu options to complete all the most common Git tasks. This guide explains how to use the graphical user interface for source control.
{% vscode %}
For more information about Git support in {% data variables.product.prodname_vscode %}, see "Using Version Control in VS Code" in the {% data variables.product.prodname_vscode %} documentation.
{% endvscode %}
{% webui %}
Source control in the {% data variables.product.prodname_vscode %} web client uses the same workflow as the {% data variables.product.prodname_vscode %} desktop application. For more information, see "Using Version Control in VS Code" in the {% data variables.product.prodname_vscode %} documentation.
{% endwebui %}
A typical workflow for updating a file using {% data variables.product.prodname_github_codespaces %} would be:
- From the default branch of your repository on {% data variables.product.prodname_dotcom %}, create a codespace. See "Creating a codespace."
- In your codespace, create a new branch to work on.
- Make your changes and save them.
- Commit the change.
- Raise a pull request.
{% webui %}
{% data reusables.codespaces.source-control %}
{% endwebui %}
{% vscode %}
{% data reusables.codespaces.source-control %}
{% endvscode %}
{% jetbrains %}
Creating or switching branches
-
Click the branch name at the right side of the status bar.
-
In the pop-up menu, do one of the following:
-
To create a new branch based on the current branch, click the name of the current branch, then choose New Branch.
Enter a name for the new branch and click Create.
-
To check out an existing branch, start typing the name of the branch you want to check out. Click the branch from the list, then click Checkout.
{% tip %}
Tip: If someone has recently changed a file on the remote repository, in the branch you switched to, you may not see those changes until you pull the changes into your codespace.
{% endtip %}
-
Committing your changes
-
At the right side of the navigation bar, click the check mark.
-
In the Commit Changes dialog box, enter a commit message.
-
Click Commit.
Alternatively, click the down arrow beside Commit and click Commit and Push.
Pulling changes from the remote repository
You can pull changes from the same branch on the remote repository and apply those changes to the copy of the repository you are working on in your codespace.
-
At the right side of the navigation bar, click the downward pointing arrow.
-
In the Update Project dialog box, choose whether you want to merge or rebase the incoming changes.
-
Click OK.
Pushing changes to your remote repository
You can push changes you've saved and committed. This applies those changes to the upstream branch on the remote repository. You might want to do this if you're not yet ready to create a pull request, or if you prefer to create a pull request on {% data variables.product.prodname_dotcom %}.
-
At the right side of the navigation bar, click the upward pointing arrow.
-
In the Push Commits dialog box, click Push.
{% endjetbrains %}








