Snapshotting Flashcards
(25 cards)
How do you stage all changes for commit?
git add .
How do you commit staged changes with a message?
git commit -m “Commit message”
How do you view the status of your working directory and staging area?
git status
How do you show the differences between the working directory and the last commit?
git diff
How do you unstage a file while retaining the changes in the working directory?
git reset HEAD filename
How do you amend the last commit with new changes?
git commit –amend
How do you restore a file from the last commit to the working directory?
git checkout – filename
How do you create a commit that includes changes from all tracked files?
git commit -a -m “Commit message”
How do you show the changes staged for the next commit?
git diff –cached
How do you list all the files that are being tracked by Git?
git ls-files
How do you stage a portion of a file’s changes?
git add -p filename
How do you show the changes made by the last commit?
git show
How do you commit all changes in the working directory with a message?
git commit -am “Commit message”
How do you revert changes in the working directory to the last commit?
git checkout .
How do you display the history of a file including renames?
git log –follow filename
How do you show a summary of changes in each commit?
git log –stat
How do you create a patch for the changes in the working directory?
git diff > patchfile.patch
How do you apply a patch file to the working directory?
git apply patchfile.patch
How do you commit changes with a verbose message
showing the diff in the editor?
How do you show the differences between two commits?
git diff commit1 commit2
How do you stage files interactively
allowing partial commits?
How do you list the files that have been modified but not yet committed?
git diff –name-only
How do you show a graphical representation of the commit history?
git log –graph
How do you display the commit history on a single line per commit?
git log –oneline