Git Flashcards
Git
a place to hide modifications while you work on something else
stash
Git
save your local modifications to a new stash, and run git reset --hard
to revert them
$ git stash save
Git
move changes from the specified stash into the workspace
$ git stash apply [stash]
Git
apply changes from the last stash and removes it
$ git stash pop
Git
list the stashes you currently have
$ git stash list
Git
show the changes recorded in the stash as a diff between the stashed state and its original parent
$ git stash show [stash]
Git
remove a single stashed state from the stash list
$ git stash drop [stash]
Git
remove all the stashed states
$ git stash clear
Git
local checkout
workspace
Git
display 1) paths that have differences between the index file and the current HEAD commit, 2) paths that have differences between the workspace and the index file, 3) paths in the workspace that are not tracked by git
$ git status
Git
display the differences not added to the index
$ git diff
Git
view changes in your workspace relative to the named commit or branch
$ git diff [commit or branch]
Git
add the current content of new or modified files to the index, staging that content for inclusion in the next commit
$ git add [file… or dir…]
Git
add the current content of modified (not new) files to the index
$ git add -u
Git
remove a file from the workspace and the index
$ git rm [file…]
Git
move a file in the workspace and the index
$ git mv [file…]
Git
commit all files changed since your last commit, except untracked files, and remove files from the index that have been removed from the workspace
$ git commit -a [-m message]
Git
update the file or dir in the workspace (does NOT switch branches)
$ git checkout [file… or dir…]
Git
match the workspace and the index to the local tree
$ git reset –hard
Git
switch branches by updating the index and the workspace to reflect the specified branch
$ git checkout [branch]
Git
create a branch and switch to it
$ git checkout -b [branch]
Git
merge changes from [branch] into current branch
$ git merge [commit or branch]
Git
revert all commits since the current branch diverged from [upstream] and then re-apply them one by one on top of changes from the HEAD of [upstream]
$ git rebase [upstream]
Git
integrate changes in the given commit into the current branch
$ git cherry-pick [commit]
Git
reverse commit specified by [commit] and commit the result
$ git revert [commit]
Git
download the repo specified by and checkout HEAD of the master branch
$ git clone [repo]
Git
incorporate changes from a remote repo into the current branch
$ git pull [remote-name]
Git
reset local repo and working tree to match a remote branch
$ git reset –hard [remote-name]/[branch]
Git
clean the working tree by recursively removing files that are not under version control, starting from the current dir
$ git clean
Git
cause git clean
to perform a ‘dry run’ to see what would be deleted
$ git clean -n
Git
files you want to commit; also called “current directory cache”, “staging area”, “cache”, or “staged files”
index
Git
remove the specified files from the next commit; resets the index but not the working tree
$ git reset HEAD [file…]
Git
undo the last commit, leaving changes in the index
git reset –soft HEAD^
Git
view the changes you staged vs the latest commit
$ git diff –cached
Git
store the current contents of the index in a new commit along with a message describing the changes
$ git commit -m [message]
Git
modify the last commit with the current index changes
$ git commit –amend
Git
a subdirectory named .git that contains all of your necessary repository files - a git repository skeleton; typical branches: master, feature-x, bugfix-y
local repository
Git
show recent commits, most recent on top
$ git log
Git
git log
option that adds branch and tag names on appropriate commits
$ git log –decorate
Git
git log
option that includes more details (files changed, insertions, and deletions)
$ git log –stat
Git
git log
option that shows commits made by a specific person
$ git log –author=[author]
Git
git log
option that shows commits made after a certain date
$ git log –after=[“MMM DD YYYY”]
Git
git log
option that shows commits made before a certain date
$ git log –before [“MMM DD YYYY”]
Git
git log
option that shows commits involved in the current merge conflicts
$ git log –merge
Git
view the changes between two arbitraty commits
$ git diff [commit] [commit]