Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Commands summary

Below we describe the steps for VSC or commands in the command line to do specific git things.

Create a new repo

Go to https://github.com/new. This will lead to a page where you can create a new repository.

Making your repo locally available

CLI
VSC

Run git clone <url> in the folder where you want the repo to be.

Protecting main

Create a new branch

CLI
VSC
GitHub

In your terminal, run: git switch -C <branch name>

alternative: git checkout -b <branch name>

Push changes

To make your changes available for others, they have to be pushed to GitHub. This is a three-phase action.

CLI
VSC

First stage the files you want to commit: git add. will stage all files. git add <filename> will stage specific files.

git commit -m "commit message" will make a snapshot of your files and attach a message to that version of the code.

git push will push the commits to GitHub. ``

Create pull request

CLI
VSC
GitHub

Review and merge

Example

CLI
VSC
GitHub

Summary

CommandDescription
git initInitialises a Git repository in that directory
git add .Adds all changes to the staging area to be committed
git add file_nameAdds changes to the specified file to the staging area to be committed
git commitCommits staged changes and allows you to write a commit message
git switch branch_nameSwitches to the specified branch
git switch -c branch_nameCreates and switches to a new branch
git switch -d SHAChecks out a past commit with the given SHA
git switch SHA file_nameChecks out the past version of a file from the commit with the given SHA
git merge branch_nameMerges the branch you are on into the specified branch
git logOutputs a log of past commits with their commit messages
git statusOutputs status, including what branch you are on and what changes are staged
git diffOutputs the differences between the working directory and most recent commit
git diff thing_a thing_bOutputs the differences between two things, such as commits and branches
git clone URLMakes a clone of the repository at the specified URL
git remote add origin URLLinks a local repository and an online repository at the specified URL
git push origin branch_namePushes local changes to the specified branch of the online repository
git pull origin branch_namePull changes from the online repository into local repository
git branch -r Checkout which branches exist
git checkout -b local_branch_name origin/remote_branch_nameCheckout remote branch as a local branch
git stashTemporarily save your uncommitted changes to be able to switch between branches
git stash popReapply the saved changes, to continue to work on them