Github Flashcards

Intro to Git and Github

1
Q

What is Git and why is it important?

A

Git is a distributed version control system (VCS) that helps developers track changes to their code and collaborate efficiently without overwriting each other’s work. It is crucial for productivity and code management in software development.

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

What is a Git repository (repo)?

A

A repository (repo) is a storage location for your project. It tracks all files and changes made to those files over time, allowing version control and collaboration.

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

What is a commit in Git?

A

A commit is a snapshot of your project at a specific point in time. It allows you to track the history of your project and revert to previous states if necessary.

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

What is the purpose of a branch in Git?

A

A branch in Git is a copy of your project that allows you to work on changes without affecting the main codebase. You can merge the branch back into the main project when you’re ready.

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

How do you resolve conflicts during a merge in Git?

A

Conflicts occur when two branches modify the same part of a file. You need to manually resolve the conflict by choosing which changes to keep and then committing the resolved version.

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

What is a good commit message?

A

A good commit message is clear, concise, and describes the purpose of the changes. It should follow a structured format, like Angular-style, with headers such as feat, fix, docs, and so on. For example, feat(user-auth): add OAuth2 login support.

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

How do you add changes in Git?

A

Use git add . to stage all modified files for commit. This prepares the changes to be committed.

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

What is the difference between git merge and git rebase?

A

Merge: Combines changes from one branch into another, creating a merge commit.

Rebase: Moves the entire feature branch to the tip of the main branch, rewriting the project history by creating new commits.

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

What is GitHub Flow?

A

GitHub Flow is a simple branching strategy for smaller teams, where the main branch always contains production-ready code. Developers create feature branches, make changes, and then open pull requests for review and merge.

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

What is GitFlow?

A

GitFlow is a more complex branching strategy that includes multiple branches, such as feature, release, and hotfix branches, to manage large projects and multiple versions.

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

What is a pull request in GitHub?

A

A pull request is a formal request to merge changes from one branch into another. It allows other developers to review the changes before they are integrated into the main codebase.

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

How do you check for differences between your working directory and the last commit?

A

Use git status to check which files are staged, modified, or untracked. To see specific changes, use git diff.

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

Why is a .gitignore file important?

A

A .gitignore file prevents unnecessary or sensitive files (like build artifacts or personal configurations) from being tracked by Git and pushed to the repository, keeping the project clean.

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

How do you create a new Git repository?

A

Use git init to initialize a new repository in the current directory.

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

Why is it important to have a written convention for Git workflows in a team?

A

A written convention ensures that all team members follow the same practices, avoiding mistakes, confusion, and merge conflicts, while also helping onboard new members more effectively.

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