Basic GIT Commands Flashcards

1
Q

working directory

A

where you have a local copy of the git repository checked out

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

staging area

A

where files are added before being committed

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

git init

A

initializes a directory as a Git repository

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

git clone [url]

A

copy a git repository so you can add to it

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

git add [file]

A

adds a new file or new modifications of an existing file to the staging area

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

git status -s

A

view the (short) status of your files in the working directory and staging area

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

git diff

A

shows diff of unstaged changes

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

git diff

A

cached

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

git diff HEAD

A

show diff of all changes (staged or unstaged)

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

git diff

A

stat

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

git commit -m ‘message’

A

records a snapshot of the staging area (all those files and modifications that have been added to it)

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

git commit -a

A

automatically stage all tracked, modified files before the commit

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

git reset HEAD

A

[file]

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

git branch

A

list your available branches

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

git branch [branchname]

A

create a new branch

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

git checkout [branchname]

A

switch to a new branch context

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

git checkout -b [branchname]

A

create and immediately switch to a branch

18
Q

git branch -d [branchname]

A

delete a branch

19
Q

git merge [branchname]

A

merge a branch context into your current one

20
Q

git log

A

show commit history of a branch

21
Q

git tag -a [tag] [commit SHA]

A

tag a point (the current commit or the given commit) in history

22
Q

git remote

A

list your remote aliases

23
Q

git remote add [alias] [url]

A

add a new remote repository of your project

24
Q

git remote rm [alias]

A

removing an existing remote alias

25
Q

git fetch [alias]

A

synchronize your local repository with another repository

26
Q

git pull

A

git fetch; git merge

27
Q

git push [alias] [branch]

A

push your new branches and data to a remote repository

28
Q

git merge [alias]/[branch]

A

merge into your current branch anything new you see on the server

29
Q

git branch -v

A

Be a little more verbose and show remote url after name

30
Q

–dry-run

A

show what would be committed

31
Q

git commit –amend

A

amend previous commit

32
Q

git config –global

A

user.email “Eric.Zhuang@monitisegroup.com”

33
Q

git checkout .

A

This checks out the current index for the current directory, throwing away all changes in files from the current directory downwards.

34
Q

–soft

A

Does not touch the index file nor the working tree at all, but requires them to be in a good order. This leaves all your changed files “Changes to be committed”, as git-status would put it.

35
Q

–hard

A

Matches the working tree and index to that of the tree being switched to. Any changes to tracked files in the working tree since are lost.

36
Q

–mixed

A

Resets the index but not the working tree (i.e., the changed files are preserved ut not marked for commit) and reports what has not been updated. This is the default ction.

37
Q

git reset HEAD@{1}

A

undo git reset HEAD~

38
Q

–amend

A

$ git reset –soft HEAD^
$ … do something else to come up with the right tree …
$ git commit -c ORIG_HEAD

39
Q

git reset –soft HEAD^

A

This is most often done when you remembered what you just committed is incomplete, or you misspelled
your commit message, or both. Leaves working tree as it was before “reset”.

40
Q

git reset –hard HEAD~3

A

Rewind the master branch to get rid of those three commits

41
Q

The Git Index

A

The index is a binary file (generally kept in .git/index) containing a sorted list of path names, each with permissions and the SHA1 of a blob object

42
Q

git ls-files

A

git ls-files can show you the contents of the index