Skip to main content

Basics of Git

A quick-reference page for Git concepts and commands used throughout this guide. If you're new to Git, start with the Version Control Lab for a guided walkthrough before using these pages as reference.

Before continuing

Make sure Workstation Setup is complete before following the procedures in this guide.

Terms

KeywordDescription
BranchPointer to a commit - see Branching Strategies
CacheLocal memory intended to temporarily store uncommitted changes
CLICommand Line Interface
CommitStores the current contents of the index in a new commit along with a log message
DirectoryFolder in file system
HEADPointer to the most recent commit on the current branch
IndexThe cache where changes are stored before they are committed
Local RepositoryWhere you keep your copy of a Git repository on your workstation
MainDefault name of the first branch
MergeJoining two or more commit histories
Pull RequestGitHub-specific term to let others know about changes you've pushed to a branch - see Create a Branch and Pull Request
Remote RepositoryA repository where you push changes for collaboration or backup
StashAnother cache, acting as a stack, where changes can be stored without committing
Working treeCurrent branch in your workspace

Common Git Commands

CommandDescription
addTrack files
branchList branches
checkoutCreate a new branch or switch to another
cloneDownload a remote repository
commitSave files to local branch
configConfigure Git settings
remoteConfigure or list remote repositories
mergeMerge another branch into the current branch
pullFetch and merge changes from remote
pushSend committed changes to remote
statusList changed files
bash — ~
$ git status
$ git checkout my-branch
$ git pull origin main

Common Shell Commands

CommandDescription
cdChange directory
lsList files in current directory
mkdirMake new directory
pwdPrint working directory