Commands Flashcards
Initialize a new Git repository
git init
Find the current state of a repository, including which files from previous commits have changed, what’s new and not currently tracked, and what has been moved or deleted
git status
Stages new or changed files, by file name
git add filename
Stages new or changed files, with anything and everything that is already tracking but is unstaged
git add -u
Takes a snapshot of the repo at any point in time, adding a message
git commit -m
Takes a snapshot of the repo at any point in time
git commit -a
Stages any unstaged changes
git add .
Used to see what has changed in a repo since the last commit
git diff
Used to see what has changed in a specific file since the last commit
git diff
Tells you how many changes have been made since the last commit and whether they are insertions or deletions
git diff —stat
Used to undo your work and go back to a commit that you haven’t shared with anyone else, also removing files and changes
git reset —hard
Used to look at a prior state of a repository
git checkout
Used to switch branches
git checkout
Used to create a new branch and switch over to it
git checkout -b
If you are in a detached head state looking at other HEADS, puts you back in the present
git checkout master