GIT Flashcards

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

How to discover which files have been changed since the last save?

A

git status

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

How to see what changes have been made to the files?

A

git diff

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

How to see which changes have been made to a specific file in a git directory?

A

git diff data/test.py

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

How to add a file to the staging area?

A

git add test.py

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

How to compare the state of files with those in the staging area?

A

git diff -r HEAD

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

How to commit with a message?

A

git commit -m “message”

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

How to see the git log of only one file?

A

git log filepath

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

How to see all changes in a specific file?

A

git annotate report.txt

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

How to remove an untracked file?

A

git clean -f filename

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

How to stage a file?

A

git add path/to/file

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

How to unstage a file?

A

git reset HEAD

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

How to undo changes that weren’t staged yet?

A

git checkout path/to/file

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

How to unstage a file?

A

git reset path/to/file

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

How to list the last two changes of a file?

A

git log -2 path/to/file

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

How to restore a certain version of a file?

A

git checkout [first few has values] path/to/file

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

How to show updated content, e.g. after a file has been restored?

A

cat path/to/file

17
Q

How to remove all files from the staging area?

A

git reset

18
Q

How to put back all files in their previous state? And with a command that means “all of the files in or below this directory”?

A

git checkout – .

19
Q

How to list all of the branches in a repository?

A

git branch

20
Q

How to switch to a branch?

A

git checkout [name of branch]

21
Q

How to delete a file in a branch?

A

git rm path/to/file

22
Q

How to create a new branch?

A

git checkout -b [name of new branch]

23
Q

How to merge two branches?

A

git merge [source branch] [destination branch]

24
Q

How to create a new repository?

A

git init [name]

25
Q

If you are in a directory that is not a git repository yet - how to convert it?

A

git init

26
Q

How to clone a repository into a new repository?

A

git clone [source path] [destination path]

27
Q

If you are in a repository how find out the number of remotes?

A

git remote

28
Q

After cloning a repository - how can more remotes be added?

A

git remote add [remote-name] URL

29
Q

How to remove existing remotes?

A

git remote rm [remote-name]

30
Q

How to pull in changes from a remote repository?

A

git pull [remote] [branch]