Git Logs and History Flashcards

1
Q

Q: How do you view the commit history of a repository?

A

A: Use git log.

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

Q: How do you view a simplified commit history in one line per commit?

A

A: Use git log –oneline.

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

Q: How do you limit the number of commits displayed in git log?

A

A: Use git log -n <number>, e.g., git log -n 5 for the last 5 commits.</number>

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

Q: How do you view the log for a specific file?

A

A: Use git log <file>.</file>

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

Q: How do you view the changes introduced by a specific commit?

A

A: Use git show <commit-hash>.</commit-hash>

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

Q: How do you view the differences between two commits?

A

A: Use git diff <commit1> <commit2>.</commit2></commit1>

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

Q: How do you search for a commit by message in the log?

A

A: Use git log –grep=”<keyword>".</keyword>

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

Q: How do you display logs with commit messages containing a specific author?

A

A: Use git log –author=”<author>".</author>

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

Q: How do you view logs from a specific date range?

A

A: Use git log –since=”YYYY-MM-DD” –until=”YYYY-MM-DD”.

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

Q: How do you include the changes (diffs) in the log output?

A

A: Use git log -p.

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

Q: How do you show a specific number of lines of diff context in the log?

A

A: Use git log -U<n>, e.g., git log -U3 for 3 lines of context.</n>

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

Q: How do you show a graphical representation of branches in the log?

A

A: Use git log –graph.

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

Q: How do you combine oneline, graph, and branch decorations in the log?

A

A: Use git log –oneline –graph –decorate.

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

Q: How do you show the commit history for a specific branch?

A

A: Use git log <branch-name>.</branch-name>

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

Q: How do you find commits that affected a specific line in a file?

A

A: Use git blame <file>.</file>

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

Q: What does git reflog do?

A

A: It shows a history of all changes to the HEAD, including changes not in git log.

17
Q

Q: How do you find the commit where a file was added?

A

A: Use git log –diff-filter=A – <file>.</file>

18
Q

Q: How do you display logs for only merge commits?

A

A: Use git log –merges.

19
Q

Q: How do you display logs for commits that are not yet pushed?

A

A: Use git log origin/<branch-name>..<branch-name>.</branch-name></branch-name>

20
Q

Q: How do you find commits where a specific file was modified?

A

A: Use git log – <file>.</file>

21
Q

Q: How do you view all commits in reverse order?

A

A: Use git log –reverse.

22
Q

Q: How do you find commits with a specific file content change?

A

A: Use git log -S “<string>".</string>

23
Q

Q: How do you filter commits by a specific committer?

A

A: Use git log –committer=”<committer>".</committer>

24
Q

Q: How do you find commits in all branches that are reachable from a specific commit?

A

A: Use git log <commit-hash> --all.</commit-hash>

25
Q

Q: How do you show the commit history in a specific format?

A

A: Use git log –pretty=<format>, e.g., git log --pretty=format:"%h - %an, %ar : %s".</format>