Git Workflow Flashcards

1
Q

Q: What is the typical sequence of steps in a basic Git workflow?

A

A: Modify files → Stage changes (git add) → Commit changes (git commit) → Push to a remote (git push).

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

Q: How do you initialise a new Git repository?

A

A: Use git init in the project directory.

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

Q: How do you clone an existing remote repository?

A

A: Use git clone <repository>.</repository>

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

Q: How do you check the status of your working directory?

A

A: Use git status.

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

Q: What is the difference between staged and unstaged changes?

A

A: Staged changes are added to the index (staging area) and ready to commit, while unstaged changes are modified files not yet added.

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

Q: How do you stage changes for a specific file?

A

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

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

Q: How do you stage all changes in your working directory?

A

A: Use git add . or git add –all.

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

Q: How do you commit staged changes with a message?

A

A: Use git commit -m “commit message”.

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

Q: How do you include all changes (staged and unstaged) in a commit without staging them first?

A

A: Use git commit -a -m “commit message”.

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

Q: How do you push your changes to a remote repository?

A

A: Use git push origin <branch>.</branch>

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

Q: How do you pull changes from a remote repository?

A

A: Use git pull.

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

Q: How do you fetch changes from a remote repository without merging them?

A

A: Use git fetch.

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

Q: What is the purpose of branching in Git?

A

A: Branching allows you to work on different features or fixes independently without affecting the main codebase.

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

Q: How do you create a new branch?

A

A: Use git branch <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 switch to a different branch?

A

A: Use git checkout <branch-name> or git switch <branch-name>.</branch-name></branch-name>

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

Q: How do you merge changes from one branch into the current branch?

A

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

17
Q

Q: How do you resolve a merge conflict?

A

A: Manually edit the conflicting files, then stage the changes (git add) and commit the merge.

18
Q

Q: What is a fast-forward merge?

A

A: A fast-forward merge occurs when the current branch’s commit history aligns with the target branch, and no new commits are created.

19
Q

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

A

A: Use git log.

20
Q

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

A

A: Use git log –oneline.

21
Q

Q: How do you undo changes in the working directory?

A

A: Use git checkout – <file> to revert changes to the last committed state.</file>

22
Q

Q: How do you remove staged changes but keep them in the working directory?

A

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

23
Q

Q: How do you completely discard changes in the working directory?

A

A: Use git checkout HEAD <file> or git restore <file>.</file></file>

24
Q

Q: What is the purpose of git stash in a workflow?

A

A: To temporarily save changes not yet committed, allowing you to switch branches or work on something else.

25
Q

Q: How do you apply the most recently stashed changes?

A

A: Use git stash apply.