Command Explanation Example and/or notes
Init Initializes a new repository on a directory.
Cd Changes the directory. Moves you to the directory you want to work on.
Ls Lists files and directories.
mkdir Makes a new directory.
Rm Removes files and directories.
Clone Clones a repository.
Status Displays the current status of the depository.
Log Displays all commits in the repository, including the SHA, author, date, and message
—online Flag of the log. Displays all the commits on one line. Reduces scrolling. Git log —oneline
—stat Flag of the log. Alters how the information is displayed. Displays files that were modified. Git log —stat
Show Shows a specific commit Git show <enter the SHA>
Add Moves files from the Working Directory to the Staging Index.
Commit Takes files from the Staging Index to the repository.
Diff Shows changes that have been made, but not committed.
branch Lists all branch names in the repository.
Branch <branch name> Creates a new branch.
Checkout <branch name> Switches from one branch to another. An asterisk appears next to the active branch.
-d Deletes a branch Branch -d <branch name>
-b Creates and switches to a new branch all at once. Checkout -b <new branch name>
Merge Combines Git branches. Git merge <name of branch you want to merge into>
Make sure you are in the Master (main) branch.
—amend Flag that alters commits, or alter or include files you forgot.
Revert Will undo changes made by the previous commit. Git revert <SHA you want to change.>
Creates a new commit.
Reset Erases commits. Git reset <SHA you want to erase>
Backup Creates a backup copy.