GitHub CLI cheat sheet.
GitHub has a set of really useful features to manage code. They can all be performed either through a command prompt (CLI) or through GitHub's website. GitHub also provides a helpful guide to get started with GitHub and git
. Here are some regular notions that you should know.
-
Your
main
branch will be the official release version of your code. -
You can make changes directly to the
main
branch.
-
Changes, in GitHub, are called commits.
-
A commit is essentially a change that was registered within a branch in a repository.
-
When working locally, changes to your files will not register until you make a commit (and, to update your online repo,
push
the commit).
-
If you don't want to be pushing commits directly to your
main
code, perhaps because they could be breaking changes, or you won't get to deploy a fully fledged feature in only 1 commit, your can create a new branch out ofmain
. -
Branches are copies of your
main
code (or copies of other branches), that can be modified, updated and developed upon without impacting themain
branch. -
Then, once your new code is ready at the branch, you can merge this branch with your
main
branch (you might need to resolve conflicting code between the two branches).
- Once you are ready, you can also request the admin to merge your branch to the
main
branch, through pull requests.
-
If you want to work on someone else's repo, you can fork their repo, which creates a copy of their repo for you to modify.
-
You can also submit a pull request to merge your copy to the upstream repo that you forked.
Here are a set of git and gh commands that you will need, if you plan to manage your project through CLI (command line).
Action | Command |
---|---|
Create a new repo | gh repo create |
Clone an existing repo | gh repo clone [REPO_LINK] |
Make a fork of an existing repo | gh repo fork [REPO_LINK] |
Set the working branch in your local project | git checkout [BRANCH_NAME] |
See a list of remote and local available branches | git branch -a |
Create a new local branch (you will also be creating a new online upstream branch when you push this new branch) | git branch [BRANCH_NAME] |
Update a branch with the most up-to-date version from GitHub | git pull OR git pull origin [BRANCH NAME] |
Add all files and changes to the index, in order to commit | git add . |
Commit | git commit -m "Commit Message" |
Push changes to GitHub | git push |
Push changes to GitHub, while linking a remote branch with a local branch | git pull --set-upstream --allow-unrelated-histories origin [UPSTREAM_BRANCH] |
Directly merging another branch into main | ON MAIN: git merge [name_of_branch] |
Create pull request | gh pr create |
View opened pull requests | gh pr view |
Merge pull request | gh pr merge [pr_number] |
-
Set up a self updating local repository in your Pi.
-
Add a local repository to self update to an already set up self updating Raspberry Pi.
-
Alternatively, you can skip the previous steps and go straight to setting up your IDE.
- Go to 6 - Set up your IDE (VSC).