Git and GitHub in Positron
Overview
Positron includes Git tooling so you can commit, pull, and push without leaving the IDE. This unit shows a minimal workflow for using GitHub from Positron.
Goals
- Know how to use Git/GitHub within Positron.
Reading
So far, we used GitHub Desktop to interact with GitHub. An alternative is to use Positron’s built-in Git support. This allows you to perform common Git tasks without leaving the IDE.
The GitHub Desktop application is generally a bit more user- and beginner-friendly, but Positron’s Git integration is convenient for day-to-day use. It is ok to use a mix of both tools as needed.
Git/GitHub in Positron
Positron has built-in Git support. You can find it on the left sidebar, it is generally the third icon from the top (the icon looks like a branch with a dot at each end). If you have a project open that is also a GitHub repository, you will see information in the Git panel that shows you what files have changed (top part) and the history of your project (bottom part).
Through this panel, you can do the same push/pull/commit workflow as in GitHub Desktop, but without leaving Positron.
If you configured GitHub Desktop to use your GitHub credentials, Positron should be able to use them as well. If you have not done that yet, you might need to set up Git/GitHub in Positron first by logging into your account. Positron will usually prompt you to do that when you try to push or pull for the first time.
Positron and Git/GitHub workflow
Let’s go through a minimal Git workflow in Positron. Open the GitHub repository you created earlier. You might even have it already open if you followed along in previous units.
If you recently did a push/pull with GitHub Desktop, the panel showing changes should be empty. You will also see in the bottom panel that the main symbol (your local repo) and the origin/main symbol (the remote repo on GitHub) are in sync and on the same line.
Now edit the README file or another file you created in that repository. After saving the file, go back to the Git panel in Positron. You should see the changed file listed in the top panel.
You will also see the Commit button. In the box above, write a short, descriptive commit message. Then click the Commit button.
You will see in the bottom panel that your local main branch is now ahead of the origin/main branch by one commit. This means you have changes locally that are not yet on GitHub.
Now click the Push button on top of the lower panel (the outgoing arrow symbol) to send your local commit to GitHub.
Summary
Positron provides an alternative to GitHub Desktop for performing Git/GitHub tasks. You can use it together with GitHub Desktop.
Further Resources
- The Positron documentation provides a few more details for using Git in Positron.
- The VS Code documentation has very detailed instructions and explanations of Git functionality in VS Code (reminder: Positron is basically VS Code).
Test yourself
Where can you find Git controls in Positron?
Positron has a Git panel in the left sidebar, shown with a branch-style icon.
- False
- True
- False
- False
After committing in Positron, what indicates your local branch is ahead of the remote?
A local commit puts your local main branch ahead of origin/main until you push.
- False
- False
- True
- False
Can you use both GitHub Desktop and Positron for Git tasks?
It is fine to use a mix of GitHub Desktop and Positron for the same repository.
- False
- False
- False
- True
Practice
- Open a GitHub repository in Positron. As needed, find one online and clone it to your computer (with or without forking it). Change a few files in the repo, then commit and push the changes to GitHub using Positron’s Git panel.