2️⃣Git Basics

Fall 2023 | Richie Sun

NOTE: Do not include angle brackets < >

For more information, check out the Git Documentation

Sharing and Updating Repositories

Git Pull

git pull <options> <repository>

Pulls changes from a remote repository into the current branch. If the current branch is behind the remote, then by default it will fast-forward the current branch to match the remote.

Git Status

git status

Displays paths that have changes between your local repository and the HEAD of the remote repository

Git Add

git add <changes to be staged>

This command updates the index using the current content found in the working tree, to prepare the content staged for the next commit. To stage all changes, use git add .

Git Commit

git commit -m <"Commit Title">

Create a new commit containing the current contents of the index and the given log message describing the changes.

Git Push

git push origin main

Updates the main branch of the remote repository based on the last local commit

Branching and Merging

Git Branch:

git branch

Lists all existing branches; the current branch will be highlighted in green and marked with an asterisk

Git Checkout:

git checkout -b <"new branch name">

or

git checkout <existing branch name>

Last updated