Git Flashcards

Create, use, and explore file repositories

1
Q

Create a local repository folder from the remote repository at ‘https://me.github.com/myrepo’

Repo&raquo_space;> Commits&raquo_space;> Staged&raquo_space;> Workspace

A

git clone https://me.github.com/myrepo

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

Create a folder named ‘project’ with an empty local repository

Commits&raquo_space;> Staged&raquo_space;> Workspace

A

git init project

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

Link all local commits to the ‘origin’ branch of the remote repository at ‘https://me.github.com/myrepo’

A

git remote add origin https://me.github.com/myrepo

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

List staged, modified, and untracked files

Workspace Staged Committed

A

git status

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

Show differences between modified files and staged files

Workspace Staged

A

git diff

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

Show differences between staged files and committed files

Staged Committed

A

git diff –cached

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

Show differences between the committed branches ‘topic1’ and ‘topic2’

A

git diff topic1 topic2

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

Move a file named ‘file’ to the staged files

Workspace&raquo_space;> Staged

A

git add file

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

Commit all staged files with the note ‘Because’

Staged&raquo_space;> Committed

A

git commit -m “Because”

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

Add to previous commit by committing all staged files and replacing the note with ‘Because’

Staged&raquo_space;> Committed

A

git commit –amend -m “Because”

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

Apply changes made on a branch named ‘topic’ to the current commit to create a new commit

Committed&raquo_space;> Staged&raquo_space;> Workspace

A

git merge topic

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

Rewrite committed history up to but not including the commit that starts with 123456

Committed&raquo_space;> Staged&raquo_space;> Workspace

A

git rebase –interactive 123456

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

Upload commits to the remote repository

Committed&raquo_space;> Repo

A

git push

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

Remove the file named ‘file’ from the staged files

A

git rm –cached file

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

Remove all staged files

Committed&raquo_space;> Staged

A

git reset HEAD

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

Reset working files and staged files to the branch named ‘topic’

Committed&raquo_space;> Staged&raquo_space;> Workspace

A

git checkout topic

17
Q

Reset working file and staged file to committed file in branch named ‘topic’

Committed&raquo_space;> Staged&raquo_space;> Workspace

A

git checkout topic file

18
Q

Undo file changes committed in the commit that starts with ‘123456’

A

git revert 123456

19
Q

List all committed branches

A

git branch

20
Q

List all committed branches and all remote repository branches

A

git branch –all

21
Q

Create a new branch called ‘topic’ in the committed files starting at the current commit

A

git branch topic

22
Q

Reset staged files to committed files at the commit that starts with 123456

Committed&raquo_space;> Staged

A

git reset 123456

23
Q

Reset working files and staged files to committed files at the commit that starts with 123456

Committed&raquo_space;> Staged&raquo_space;> Workspace

A

git reset –hard 123456

24
Q

Apply current changes to the branch named ‘topic’ in the committed files and move to the new commit

Committed&raquo_space;> Staged&raquo_space;> Workspace

A

git rebase topic

25
Q

List the contents of all stashes with their ID numbers

A

git stash list

26
Q

Backup working changes and staged changes with an ID and reset working and staged files with committed files

Workspace&raquo_space;> Stash
Staged&raquo_space;> Stash
Committed&raquo_space;> Staged&raquo_space;> Workspace

A

git stash push –include-untracked

27
Q

Apply the stashed files labeled ‘id’ to the staged and working files

Stash&raquo_space;> Staged
Stash&raquo_space;> Workspace

A

git stash apply id

28
Q

Delete stash labeled ‘id’

A

git stash drop id

29
Q

Delete all stashed changes

A

git stash clear

30
Q

List all committed tags

A

git tag

31
Q

Mark current commit with a 2018-11 tag

A

git tag 2018-11

32
Q

Mark current commit with a ‘v1.0.0’ tag and a ‘Note’ note

A

git tag -a v1.0.0 -m “Note”

33
Q

Upload committed tags to remote repository

Committed&raquo_space;> Repo

A

git push –tags

34
Q

Show a condensed history graph of the committed files

A

git log –graph –oneline

35
Q

Show the last three commits for the current branch

A

git log -3

36
Q

Show detailed information about the commit that starts with 123456

A

git show 123456

37
Q

Show the last person to touch each line of ‘file’

A

git blame file

38
Q

Show the history of git commands that affected the commit that starts with 123456

A

git reflog 123456

39
Q

Create an empty local repository in the current folder

Commits&raquo_space;> Staged&raquo_space;> Workspace

A

git init