Git Flashcards

(114 cards)

1
Q

Git

a place to hide modifications while you work on something else

A

stash

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Git

save your local modifications to a new stash, and run git reset --hard to revert them

A

$ git stash save

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Git

move changes from the specified stash into the workspace

A

$ git stash apply [stash]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Git

apply changes from the last stash and removes it

A

$ git stash pop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Git

list the stashes you currently have

A

$ git stash list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Git

show the changes recorded in the stash as a diff between the stashed state and its original parent

A

$ git stash show [stash]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Git

remove a single stashed state from the stash list

A

$ git stash drop [stash]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Git

remove all the stashed states

A

$ git stash clear

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Git

local checkout

A

workspace

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

A

$ git status

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Git

display the differences not added to the index

A

$ git diff

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Git

view changes in your workspace relative to the named commit or branch

A

$ git diff [commit or branch]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Git

add the current content of new or modified files to the index, staging that content for inclusion in the next commit

A

$ git add [file… or dir…]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Git

add the current content of modified (not new) files to the index

A

$ git add -u

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Git

remove a file from the workspace and the index

A

$ git rm [file…]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Git

move a file in the workspace and the index

A

$ git mv [file…]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

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

A

$ git commit -a [-m message]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Git

update the file or dir in the workspace (does NOT switch branches)

A

$ git checkout [file… or dir…]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Git

match the workspace and the index to the local tree

A

$ git reset –hard

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Git

switch branches by updating the index and the workspace to reflect the specified branch

A

$ git checkout [branch]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Git

create a branch and switch to it

A

$ git checkout -b [branch]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Git

merge changes from [branch] into current branch

A

$ git merge [commit or branch]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

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]

A

$ git rebase [upstream]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Git

integrate changes in the given commit into the current branch

A

$ git cherry-pick [commit]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
# Git reverse commit specified by [commit] and commit the result
$ git revert [commit]
26
# Git download the repo specified by and checkout HEAD of the master branch
$ git clone [repo]
27
# Git incorporate changes from a remote repo into the current branch
$ git pull [remote-name]
28
# Git reset local repo and working tree to match a remote branch
$ git reset --hard [remote-name]/[branch]
29
# Git clean the working tree by recursively removing files that are not under version control, starting from the current dir
$ git clean
30
# Git cause `git clean` to perform a 'dry run' to see what would be deleted
$ git clean -n
31
# Git files you want to commit; also called "current directory cache", "staging area", "cache", or "staged files"
index
32
# Git remove the specified files from the next commit; resets the index but not the working tree
$ git reset HEAD [file...]
33
# Git undo the last commit, leaving changes in the index
git reset --soft HEAD^
34
# Git view the changes you staged vs the latest commit
$ git diff --cached
35
# Git store the current contents of the index in a new commit along with a message describing the changes
$ git commit -m [message]
36
# Git modify the last commit with the current index changes
$ git commit --amend
37
# 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
38
# Git show recent commits, most recent on top
$ git log
39
# Git `git log` option that adds branch and tag names on appropriate commits
$ git log --decorate
40
# Git `git log` option that includes more details (files changed, insertions, and deletions)
$ git log --stat
41
# Git `git log` option that shows commits made by a specific person
$ git log --author=[author]
42
# Git `git log` option that shows commits made after a certain date
$ git log --after=["MMM DD YYYY"]
43
# Git `git log` option that shows commits made before a certain date
$ git log --before ["MMM DD YYYY"]
44
# Git `git log` option that shows commits involved in the current merge conflicts
$ git log --merge
45
# Git view the changes between two arbitraty commits
$ git diff [commit] [commit]
46
# Git list all existing branches
$ git branch
47
# Git `git branch` option that includes remote branches
$ git branch -a
48
# Git delete a specified branch
$ git branch -d [branch]
49
# Git force delete a specified branch
$ git branch -D [branch]
50
# Git create a new local branch that tracks a remote branch
$ git branch --track [new-branch] [remote/branch]
51
# Git download objects and refs from another repo
$ git fetch [remote] [refspec]
52
# Git update the server with your commits that are COMMON between your local copy and the server; local branches that were never pushed to the server in the first place are not shared
$ git push
53
# Git push a new (or existing) branch to the remote repo
$ git push [remote] [branch]
54
# Git push a new branch to a repote repository with a different name
$ git push [remote] [branch] : [branch]
55
# Git versions of your project that are hosted on a network, ensuring all your changes are available for other developers; the default name is 'origin'
upstream repository
56
# Git list remote branches
$ git branch -r
57
# Git remove a remote branch; literally 'push nothing to this branch'
$ git push [remote] : [branch]
58
# Git stash
a place to hide modifications while you work on something else
59
# Git $ git stash save
save your local modifications to a new stash, and run `git reset --hard` to revert them
60
# Git $ git stash apply [stash]
move changes from the specified stash into the workspace
61
# Git $ git stash pop
apply changes from the last stash and removes it
62
# Git $ git stash list
list the stashes you currently have
63
# Git $ git stash show [stash]
show the changes recorded in the stash as a diff between the stashed state and its original parent
64
# Git $ git stash drop [stash]
remove a single stashed state from the stash list
65
# Git $ git stash clear
remove all the stashed states
66
# Git workspace
local checkout
67
# Git $ git status
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
68
# Git $ git diff
display the differences not added to the index
69
# Git $ git diff [commit or branch]
view changes in your workspace relative to the named commit or branch
70
# Git $ git add [file... or dir...]
add the current content of new or modified files to the index, staging that content for inclusion in the next commit
71
# Git $ git add -u
add the current content of modified (not new) files to the index
72
# Git $ git rm [file...]
remove a file from the workspace and the index
73
# Git $ git mv [file...]
move a file in the workspace and the index
74
# Git $ git commit -a [-m message]
commit all files changed since your last commit, except untracked files, and remove files from the index that have been removed from the workspace
75
# Git $ git checkout [file... or dir...]
update the file or dir in the workspace (does NOT switch branches)
76
# Git $ git reset --hard
match the workspace and the index to the local tree
77
# Git $ git checkout [branch]
switch branches by updating the index and the workspace to reflect the specified branch
78
# Git $ git checkout -b [branch]
create a branch and switch to it
79
# Git $ git merge [commit or branch]
merge changes [branch] from into current branch
80
# Git $ git rebase [upstream]
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]
81
# Git $ git cherry-pick [commit]
integrate changes in the given commit into the current branch
82
# Git $ git revert [commit]
reverse commit specified by [commit] and commit the result
83
# Git $ git clone [repo]
download the repo specified by and checkout HEAD of the master branch
84
# Git $ git pull [remote-name]
incorporate changes from a remote repo into the current branch
85
# Git $ git reset --hard [remote-name]/[branch]
reset local repo and working tree to match a remote branch
86
# Git $ git clean
clean the working tree by recursively removing files that are not under version control, starting from the current dir
87
# Git $ git clean -n
cause `git clean` to perform a 'dry run' to see what would be deleted
88
# Git index
files you want to commit; also called "current directory cache", "staging area", "cache", or "staged files"
89
# Git $ git reset HEAD [file...]
remove the specified files from the next commit; resets the index but not the working tree
90
# Git git reset --soft HEAD^
undo the last commit, leaving changes in the index
91
# Git $ git diff --cached
view the changes you staged vs the latest commit
92
# Git $ git commit -m [message]
store the current contents of the index in a new commit along with a message describing the changes
93
# Git $ git commit --amend
modify the last commit with the current index changes
94
# Git local repository
a subdirectory named .git that contains all of your necessary repository files - a git repository skeleton; typical branches: master, feature-x, bugfix-y
95
# Git $ git log
show recent commits, most recent on top
96
# Git $ git log --decorate
`git log` option that adds branch and tag names on appropriate commits
97
# Git $ git log --stat
`git log` option that includes more details (files changed, insertions, and deletions)
98
# Git $ git log --author=[author]
`git log` option that shows commits made by a specific person
99
# Git $ git log --after=["MMM DD YYYY"]
`git log` option that shows commits made after a certain date
100
# Git $ git log --before ["MMM DD YYYY"]
`git log` option that shows commits made before a certain date
101
# Git $ git log --merge
`git log` option that shows commits involved in the current merge conflicts
102
# Git $ git diff [commit] [commit]
view the changes between two arbitraty commits
103
# Git $ git branch
list all existing branches
104
# Git $ git branch -a
`git branch` option that includes remote branches
105
# Git $ git branch -d [branch]
delete a specified branch
106
# Git $ git branch -D [branch]
force delete a specified branch
107
# Git $ git branch --track [new-branch] [remote/branch]
create a new local branch that tracks a remote branch
108
# Git $ git fetch [remote] [refspec]
download objects and refs from another repo
109
# Git $ git push
update the server with your commits that are COMMON between your local copy and the server; local branches that were never pushed to the server in the first place are not shared
110
# Git $ git push [remote] [branch]
push a new (or existing) branch to the remote repo
111
# Git $ git push [remote] [branch] : [branch]
push a new branch to a repote repository with a different name
112
# Git upstream repository
versions of your project that are hosted on a network, ensuring all your changes are available for other developers; the default name is 'origin'
113
# Git $ git branch -r
list remote branches
114
# Git $ git push [remote] : [branch]
remove a remote branch; literally 'push nothing to this branch'