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
| Keyword | Description |
|---|---|
Branch | Pointer to a commit - see Branching Strategies |
Cache | Local memory intended to temporarily store uncommitted changes |
CLI | Command Line Interface |
Commit | Stores the current contents of the index in a new commit along with a log message |
Directory | Folder in file system |
HEAD | Pointer to the most recent commit on the current branch |
Index | The cache where changes are stored before they are committed |
Local Repository | Where you keep your copy of a Git repository on your workstation |
Main | Default name of the first branch |
Merge | Joining two or more commit histories |
Pull Request | GitHub-specific term to let others know about changes you've pushed to a branch - see Create a Branch and Pull Request |
Remote Repository | A repository where you push changes for collaboration or backup |
Stash | Another cache, acting as a stack, where changes can be stored without committing |
Working tree | Current branch in your workspace |
Common Git Commands
| Command | Description |
|---|---|
add | Track files |
branch | List branches |
checkout | Create a new branch or switch to another |
clone | Download a remote repository |
commit | Save files to local branch |
config | Configure Git settings |
remote | Configure or list remote repositories |
merge | Merge another branch into the current branch |
pull | Fetch and merge changes from remote |
push | Send committed changes to remote |
status | List changed files |
bash — ~
$ git status $ git checkout my-branch $ git pull origin main
Common Shell Commands
| Command | Description |
|---|---|
cd | Change directory |
ls | List files in current directory |
mkdir | Make new directory |
pwd | Print working directory |