Git Flashcards
(114 cards)
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]