Git commands Flashcards

(77 cards)

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
Show all remote repositories
git remote -v
26
Push the main branch to the remote repository known as origin
git push origin main
27
Pull from the remote repository known as origin
git pull origin
28
Remove the remote known as origin
git remote rm origin
29
Clone the remote repository https://github.com/Name/test.git into the current directory
git clone https://github.com/Name/test.git
30
Clone the remote repository https://github.com/Name/test.git into the current directory under the name Name
git clone https://github.com/Name/test.git Name
31
Create a new branch called name
git branch name
32
Change to the branch called name
git checkout name
33
Merge the branch called name into the current branch
git merge name
34
Remove the branch called name
git branch -d name
35
Create a new branch called name and change to it
git checkout -b name
36
Show all the existing branches and highlight the current one
git branch
37
Show all remote branches
git branch -r
38
Show all remote branches of remote repository origin in relation to the local branches
git remote show origin
39
Delete the branch name of the remote repository origin
git push origin :name
40
Delete the branch name even if it isn't fully merged
git branch -D name
41
Remove all stale branches of the remote repository origin
git remote prune origin
42
Push the local branch name to the branch main of the remote repository called origin
git push origin name:main
43
Show all tags
git tag
44
Change to tag v1.0
git checkout v.1.0
45
Add a new tag called v1.1 with the description "Message"
git tag -a v1.1 -m "Message"
46
Push all local tags to the remote repository called origin
git push --tags origin
47
Get all changes from the remote repository without merging
git fetch
48
Synchronize all fetched commits with local commits
git rebase
49
Apply all commits from branch main to the current branch
git rebase main
50
Continue synchronizing two branches, after having fixed a conflict
git rebase --continue
51
While synchronizing two branches, skip a commit causing a conflict
git rebase --skip
52
Cancel an active synchronization of two branches, after running into a conflict
git rebase --abort
53
Enable colorization of git output
git config --global color.ui true
54
Show commit history, with every commit only taking up a single line
git log --pretty=oneline
55
The placeholder for the author date
%ad
56
The placeholder for the author name
%an
57
The placeholder for the SHA hash
%h
58
The placeholder for the subject
%s
59
The placeholder for the ref names
%d
60
Show the commit history every commit being formatted with "%h %ad- %s [%an]"
git log --pretty=format:"%h %ad- %s [%an]"
61
Show the commit history with all the changes made
git log -p
62
Show the commit history with all the changes made and all the commit descriptions only taking up a singe line
git log --oneline -p
63
Show the commit history showing additional stats
git log --stat
64
Show the commit history showing the branch/merge graph
git log --graph
65
Show the commit history starting a week ago
git log --since=1.week.ago
66
Show the commit history until 2 hours ago
git log --until=2.hour.ago
67
Show the commit history between 1 year ago and 4 months ago
git log --since=1.year.ago --until=4.month.ago
68
Show the commit history between January 2015 March 2016
git log --since=2015-01-01 --until=2016-03-01
69
Show the difference between 5 commits ago and 2 commits ago
git diff Head~5..Head^^
70
Compare the branch main with the branch name
git diff main name
71
Compare the repository during July 2021 with the repository 1 year ago
git diff --since=2021-07-01 --until=1.year.ago
72
Show all the changes made to README.html together with some of their commit information
git blame README.txt
73
Stop tracking the file README.txt
git rm --cached README.txt
74
Use vim as your editor for messages
git config --global core.editor vim
75
Show all configurations
git config --list
76
Show which email is set for this repository
git config user.email
77
Save the command "log --pretty=format: '%h %s [%an]' --graph" as mylog
git config --global alias.mylog "log --pretty=format: '%h %s [%an]' --graph"