Git commands Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Stage file README.txt for commit

A

git add README.txt

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

Commit all staged files

A

git commit

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

Commit all staged files with the message “Message”

A

git commit -m “Message”

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

Commit all files

A

git commit -a

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

Commit all files with the message “Message”

A

git commit -a -m “Message”

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

Set your name to “Name”

A

git config –global user.name “Name”

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

Set your email to Name@mail.com

A

git config –global user.email Name@mail.com

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

Initialize a new repository in the current directory

A

git init

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

Show the commit history of the current repository

A

git log

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

Show all unstaged changes to the repository

A

git diff

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

Show all staged changes to the repository

A

git diff –staged

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

Show all unstaged changes to the file README.txt

A

git diff README.txt

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

Show all staged changes to the file README.txt

A

git diff –staged README.txt

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

Stage all files for commit

A

git add –all

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

Get the status of all files in the current directory (which are tracked, changed, staged etc.)

A

git status

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

Commit the files README.txt and LICENSE.txt

A

git commit README.txt LICENSE.txt

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

Commit all .txt files in the project

A

git commit “*.txt”

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

Stage all .txt files in the current directory for commit

A

git add *.txt

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

Stage the directory src/ for commit

A

git add src/

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

Unstage README.txt

A

git reset HEAD README.txt

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

Undo the last commit and move all changed files back to staging

A

git reset –soft HEAD^

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

Completely undo the last 2 commits

A

git reset –hard HEAD^^

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

Add all staged changes to the last commit with the message “Message”

A

git commit –amend -m “Message”

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

Link the current repository to the remote repository https://github.com/Name/test.git and refer to it as origin

A

git remote add origin https://github.com/Name/test.git

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

Show all remote repositories

A

git remote -v

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

Push the main branch to the remote repository known as origin

A

git push origin main

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

Pull from the remote repository known as origin

A

git pull origin

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

Remove the remote known as origin

A

git remote rm origin

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

Clone the remote repository https://github.com/Name/test.git into the current directory

A

git clone https://github.com/Name/test.git

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

Clone the remote repository https://github.com/Name/test.git into the current directory under the name Name

A

git clone https://github.com/Name/test.git Name

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

Create a new branch called name

A

git branch name

32
Q

Change to the branch called name

A

git checkout name

33
Q

Merge the branch called name into the current branch

A

git merge name

34
Q

Remove the branch called name

A

git branch -d name

35
Q

Create a new branch called name and change to it

A

git checkout -b name

36
Q

Show all the existing branches and highlight the current one

A

git branch

37
Q

Show all remote branches

A

git branch -r

38
Q

Show all remote branches of remote repository origin in relation to the local branches

A

git remote show origin

39
Q

Delete the branch name of the remote repository origin

A

git push origin :name

40
Q

Delete the branch name even if it isn’t fully merged

A

git branch -D name

41
Q

Remove all stale branches of the remote repository origin

A

git remote prune origin

42
Q

Push the local branch name to the branch main of the remote repository called origin

A

git push origin name:main

43
Q

Show all tags

A

git tag

44
Q

Change to tag v1.0

A

git checkout v.1.0

45
Q

Add a new tag called v1.1 with the description “Message”

A

git tag -a v1.1 -m “Message”

46
Q

Push all local tags to the remote repository called origin

A

git push –tags origin

47
Q

Get all changes from the remote repository without merging

A

git fetch

48
Q

Synchronize all fetched commits with local commits

A

git rebase

49
Q

Apply all commits from branch main to the current branch

A

git rebase main

50
Q

Continue synchronizing two branches, after having fixed a conflict

A

git rebase –continue

51
Q

While synchronizing two branches, skip a commit causing a conflict

A

git rebase –skip

52
Q

Cancel an active synchronization of two branches, after running into a conflict

A

git rebase –abort

53
Q

Enable colorization of git output

A

git config –global color.ui true

54
Q

Show commit history, with every commit only taking up a single line

A

git log –pretty=oneline

55
Q

The placeholder for the author date

A

%ad

56
Q

The placeholder for the author name

A

%an

57
Q

The placeholder for the SHA hash

A

%h

58
Q

The placeholder for the subject

A

%s

59
Q

The placeholder for the ref names

A

%d

60
Q

Show the commit history every commit being formatted with “%h %ad- %s [%an]”

A

git log –pretty=format:”%h %ad- %s [%an]”

61
Q

Show the commit history with all the changes made

A

git log -p

62
Q

Show the commit history with all the changes made and all the commit descriptions only taking up a singe line

A

git log –oneline -p

63
Q

Show the commit history showing additional stats

A

git log –stat

64
Q

Show the commit history showing the branch/merge graph

A

git log –graph

65
Q

Show the commit history starting a week ago

A

git log –since=1.week.ago

66
Q

Show the commit history until 2 hours ago

A

git log –until=2.hour.ago

67
Q

Show the commit history between 1 year ago and 4 months ago

A

git log –since=1.year.ago –until=4.month.ago

68
Q

Show the commit history between January 2015 March 2016

A

git log –since=2015-01-01 –until=2016-03-01

69
Q

Show the difference between 5 commits ago and 2 commits ago

A

git diff Head~5..Head^^

70
Q

Compare the branch main with the branch name

A

git diff main name

71
Q

Compare the repository during July 2021 with the repository 1 year ago

A

git diff –since=2021-07-01 –until=1.year.ago

72
Q

Show all the changes made to README.html together with some of their commit information

A

git blame README.txt

73
Q

Stop tracking the file README.txt

A

git rm –cached README.txt

74
Q

Use vim as your editor for messages

A

git config –global core.editor vim

75
Q

Show all configurations

A

git config –list

76
Q

Show which email is set for this repository

A

git config user.email

77
Q

Save the command “log –pretty=format: ‘%h %s [%an]’ –graph” as mylog

A

git config –global alias.mylog “log –pretty=format: ‘%h %s [%an]’ –graph”