GIT Flashcards
(30 cards)
How to discover which files have been changed since the last save?
git status
How to see what changes have been made to the files?
git diff
How to see which changes have been made to a specific file in a git directory?
git diff data/test.py
How to add a file to the staging area?
git add test.py
How to compare the state of files with those in the staging area?
git diff -r HEAD
How to commit with a message?
git commit -m “message”
How to see the git log of only one file?
git log filepath
How to see all changes in a specific file?
git annotate report.txt
How to remove an untracked file?
git clean -f filename
How to stage a file?
git add path/to/file
How to unstage a file?
git reset HEAD
How to undo changes that weren’t staged yet?
git checkout path/to/file
How to unstage a file?
git reset path/to/file
How to list the last two changes of a file?
git log -2 path/to/file
How to restore a certain version of a file?
git checkout [first few has values] path/to/file
How to show updated content, e.g. after a file has been restored?
cat path/to/file
How to remove all files from the staging area?
git reset
How to put back all files in their previous state? And with a command that means “all of the files in or below this directory”?
git checkout – .
How to list all of the branches in a repository?
git branch
How to switch to a branch?
git checkout [name of branch]
How to delete a file in a branch?
git rm path/to/file
How to create a new branch?
git checkout -b [name of new branch]
How to merge two branches?
git merge [source branch] [destination branch]
How to create a new repository?
git init [name]