Git Flashcards

1
Q

Git: how can you go back to where you have started?

A

git rebase –abort

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

Git: how can you show the files of the recent commit?

A

git show

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

Git: how to show the commit refs in oneline format?

A

git log –pretty=oneline

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

Git: how to delete anything about a file in history?

A

git filter-branch –index-filter ‘git rm -r –cached –ignore-unmatch ‘ HEAD

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

Git: how to compare two branches?

A

git diff branch1..branch2

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

Git: how to show diff of file (not added or uncommitted for example)?

A

git diff filename

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

Git: how to reset single file to head?

A

git checkout filename

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

Git: how to undo add of file?

A

git reset filename

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

Git: how to change previous commit message?

A

git commit –amend

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

Git: how to take local files when merging conflicts?

A

grep -lr ‘«««

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

Git: how to mark all conflicted files as solved?

A

git add -u

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

Git: how to checkout a specific commit for a single file

A

git checkout ### filename

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

Git: how to show log to single file?

A

git log filename

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

How to show log with short commit hashes?

A

git log –abbrev-commit

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

Git: how to search for commits in history related tp a single file?

A

git log -S’xxx’ – filename.y

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

Git: how to restore lost commits?

A

git reflog

17
Q

Git: How to show diff between two commits without merges ?

A

git log –no-merges -p branch_start..branch_end

18
Q

Git: How to remove one single commit in history?

A

git rebase –onto commit-hash^ commit-hash HEAD

19
Q

Git: how to Merge Remote Branch Info Current?

A

git pull origin BRANCH_NAME