Git Fundamentals Flashcards

1
Q

Q: What is Git?

A

A: Git is a distributed version control system that tracks changes in source code during software development.

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

Q: What is a repository in Git?

A

A: A repository (repo) is a directory that stores your project files and the history of changes tracked by Git.

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

Q: How do you initialise a Git repository?

A

A: Use the command git init to create a new Git repository in the current directory.

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

Q: What command is used to check the status of a Git repository?

A

A: Use git status to display the current state of the repository, including staged and unstaged changes.

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

Q: What is a commit in Git?

A

A: A commit is a snapshot of the changes in your repository. It represents a specific point in the project’s history.

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

Q: How do you stage changes in Git?

A

A: Use git add <file> to stage changes or git add . to stage all changes in the current directory.</file>

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

Q: How do you create a commit in Git?

A

A: Use git commit -m “commit message” to save staged changes with a descriptive message.

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

Q: What does git clone do?

A

A: git clone <repository> copies a remote repository to your local machine.</repository>

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

Q: How do you view the commit history?

A

A: Use git log to display the commit history of the repository.

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

Q: What is a remote repository?

A

A: A remote repository is a version of your repository hosted on a server, such as GitHub, to enable collaboration.

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

Q: How do you link a remote repository to a local repository?

A

A: Use git remote add origin <repository> to connect to a remote repository.</repository>

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

Q: What command is used to push changes to a remote repository?

A

A: Use git push origin <branch> to upload local changes to the remote repository.</branch>

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

Q: What does git pull do?

A

A: git pull fetches changes from a remote repository and merges them into the current branch.

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

Q: What is the difference between git fetch and git pull?

A

A: git fetch downloads changes from a remote repository without merging, while git pull fetches and merges changes.

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

Q: How do you create a new branch in Git?

A

A: Use git branch <branch-name> to create a new branch.</branch-name>

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

Q: How do you switch to another branch?

A

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

17
Q

Q: What is the .gitignore file used for?

A

A: .gitignore specifies files or patterns to be excluded from version control.

18
Q

Q: How do you delete a branch in Git?

A

A: Use git branch -d <branch-name> to delete a branch locally.</branch-name>

19
Q

Q: How do you check the differences between files?

A

A: Use git diff to show changes between the working directory and the staging area or between commits.

20
Q

Q: What is HEAD in Git?

A

A: HEAD refers to the current branch or commit you are working on.

21
Q

Q: How do you undo the last commit?

A

A: Use git reset –soft HEAD~1 to undo the last commit but keep the changes staged.

22
Q

Q: What does git stash do?

A

A: git stash temporarily saves changes not yet committed, allowing you to switch branches or work cleanly.

23
Q

Q: How do you apply a stashed change?

A

A: Use git stash apply to reapply the most recent stashed changes.

24
Q

Q: How do you list all stashes in Git?

A

A: Use git stash list to view all stashed changes.

25
Q

Q: How do you configure Git with your name and email?

A

A: Use git config –global user.name “Your Name” and git config –global user.email “your_email@example.com”.