# Git workflow

## Terminal [Permalink for this section](/content/docs/learn/repositories/getting-started/git-workflow#terminal/index.html)

When working locally, you likely use the terminal to interact with Git. On CodeSandbox, Git commands will work as expected with two exceptions, changing and renaming the branch.

Each branch runs on its own virtual machine (VM). So instead of checking out a branch within the same VM, when you change a branch on CodeSandbox, we will navigate you to the branch running on its respective VM.

However, if you currently use `git checkout` to update your branch from target, you will need to conform to the following:

- If you use `checkout` with `rebase` you should use the following command instead: `git rebase origin/main my-current-branch`. This is [a more efficient way (opens in a new tab)](https://stackoverflow.com/a/56840200) and bypasses the need for a checkout
- If you use `merge` you should use the upper left pill in the UI which appears automatically when you are behind your target

If you need to rename the branch, please double click the name in the topbar and change it there.

## Source Control panel [Permalink for this section](/content/docs/learn/repositories/getting-started/git-workflow#source-control-panel/index.html)

After you have made some changes to your code and saved them ( `⌘ + S` or `Ctrl + S`), you will notice a notification next to the git icon on the left sidebar.

Clicking that icon or using `⌃ ⇧ G` or `Ctrl + ⇧ + G` reveals the Source Control panel, which will contain a list of your previous commits, as well as all uncommitted changes.

⚠️

New branches are not automatically created on GitHub. We only push the branch to GitHub when you create a commit or rename the branch.

## Committing changes [Permalink for this section](/content/docs/learn/repositories/getting-started/git-workflow#committing-changes/index.html)

Above the "Commit" button, you will find a text field where you can input a commit message. Then, when you click the "Commit" button, we commit the changes to the branch. Finally, when you click "Sync changes", the commit will sync to GitHub.

💡

You can also commit changes using the terminal. This is especially useful if you're working with a repository from GitLab or another non-GitHub git provider, as our git panel currently only supports GitHub repos.

## Creating a pull request [Permalink for this section](/content/docs/learn/repositories/getting-started/git-workflow#creating-a-pull-request/index.html)

After you have committed some changes, you can create a pull request, either using the "Create PR" button at the top right of the editor, or clicking on the "Create Pull Request" icon shown at the top of the Source Control panel.

Then, you will be redirected to GitHub, where you will be able to add the final details of the PR.

💡

The left sidebar also contains a "GitHub Pull Requests" panel that allows you to create, view and manage PRs.

## Reviewing a PR [Permalink for this section](/content/docs/learn/repositories/getting-started/git-workflow#reviewing-a-pr/index.html)

CodeSandbox has a unique set of features that improve the PR review process.

Setting this up requires some additional one-time configuration, so see more details about this setup and workflow on the [code reviews](/content/docs/learn/repositories/review/index.html) page.

[Environment setup](/content/docs/learn/repositories/getting-started/environment-setup "Environment setup"/index.html) [PR configuration](/content/docs/learn/repositories/getting-started/gha-previews "PR configuration"/index.html)
