Inno 3.2 Version Control Flashcards

(45 cards)

1
Q

What is a repository in Git?

A

A repository (repo) is a storage space for your project’s code, including all its history, branches, and commits.

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

What is a commit in Git?

A

A: A commit is a snapshot of changes in your codebase. It records what was changed, when, and by whom.

SNAPSHOT OF CHANGES

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

Q: What is a branch in Git?

A

A: A branch is an independent line of development, allowing you to work on features or fixes without affecting the main codebase.

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

Q: What is a merge in Git?

A

A: Merging combines changes from one branch into another, usually integrating a feature branch back into the main branch.

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

Q: What is a merge conflict?

A

A: A conflict occurs when Git can’t automatically combine changes from two branches — manual resolution is needed.

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

Q: What does it mean to clone a repository?

A

A: Cloning creates a local copy of a remote repository so you can work with it on your machine.

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

Q: What does pull do in Git?

A

A: git pull fetches and integrates changes from a remote repository into your current local branch.

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

Q: What does push do in Git?

A

A: git push sends your local commits to a remote repository.

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

Q: What does fetch do in Git?

A

A: git fetch retrieves the latest commits from the remote but does not merge them into your local branch automatically.

RETRIVES THE LAST COMMITS BUT DOES NOT MERGES IT AUTOMATICLLY

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

Q: What does git init do?

A

A: It initializes a new Git repository in your current folder.

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

Q: What does git clone do?

A

A: It creates a local copy of an existing remote repository.

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

Q: What does git add do?

A

A: It stages changes, preparing them to be committed.

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

Q: What does git commit do?

A

A: It saves the staged changes to the local repository with a message.

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

Q: What does git log show?

A

A: It displays the commit history of the current branch.

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

Q: What does git branch do?

A

A: It lists, creates, or deletes branches.

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

Q: What does git checkout do?

A

A: It switches between branches or restores files.

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

Q: What does git merge do?

A

A: It integrates changes from one branch into the current branch.

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

Q: What does git remote do?

A

A: It manages connections to remote repositories.

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

Q: What does git push do?

A

A: It uploads your local commits to the remote repository.

20
Q

Q: What is the Git Flow branching model?

A

A: It uses branches like main, develop, feature/, and hotfix/ to manage release cycles and environments.

21
Q

Q: What is Trunk-Based Development?

A

A: All developers work on a single main branch with short-lived feature branches — encourages CI and fast delivery.

EVERYONE WORKS ON SINGLE BRANCH WITH SHORT LIVED FEATURE BRANCH

22
Q

Q: What are SSH keys in Git?

A

A: SSH keys authenticate you securely with remote Git servers without using a password every time.

23
Q

Q: How is access control typically handled in Git repositories?

A

A: With roles (e.g., read, write, admin) on platforms like GitHub/GitLab, often combined with branch protection rules.

24
Q

Q: What is rebasing in Git?

A

A: Rebasing moves or combines commits from one branch onto another to create a cleaner history.

25
Q: When should you not rebase?
A: Avoid rebasing shared/public branches, as it rewrites history and can confuse collaborators.
26
Q: What is stashing in Git?
A: git stash temporarily saves changes without committing them, allowing you to switch branches safely. SAVE CHANGES WITHOUT COMMITING
27
Q: What does cherry-pick do in Git?
A: **It applies a specific commit from one branch onto another** — useful for hotfixes or isolated changes. APPLIES SPECIIF COMMITS
28
Q: What is git squash?
A: **Squashing combines multiple commits into one to create a cleaner commit history before merging.** MERGING MULTIPLE COMMITS INTO ONE COMMIT BEFORE MERGING
29
Q: How can Git be used for backups?
A: Pushing regularly to a remote repository acts as a backup. You can also clone repos to different machines.
30
Q: What is the difference between merge and rebase, and when should you use each?
A: merge preserves the full history by creating a new commit that combines two branches, keeping the original commit structure. It's useful when working with a team, as it avoids rewriting history. **rebase rewrites the commit history by moving commits from one branch to another, creating a linear history**. It's great for cleaning up local commits before pushing. Use merge for shared branches, and rebase only for local or private ones to avoid conflicts with teammates.
31
Q: What is an interactive rebase (git rebase -i) and what can you do with it?
A: git rebase -i allows you to interactively edit, squash, reorder, or remove commits before integrating them into another branch. It’s commonly used to clean up messy commit history before pushing or opening a pull request. With interactive rebase, you can: Combine multiple commits into one (squash) Edit a commit message (reword) Delete unnecessary commits Reorder commit sequence It's a powerful tool, but should be used with care. I CAN EDIT, SQUASH, REORDER
32
Q: What is a Git hook, and what are some common use cases?
A: **A Git hook is a script that runs automatically in response to Git events**, such as committing, pushing, or merging. Git hooks are stored in the .git/hooks/ directory. Examples include: pre-commit: run linters/tests before allowing a commit pre-push: prevent push if tests fail commit-msg: enforce commit message format Hooks help enforce policies and automate checks locally, improving quality and consistency. SCRIPT THAT TUN AUTOMATICLY IN REPOSNE TO GIT EVENTS
33
Q: What is the difference between pull and fetch + merge?
A: **git pull is a convenience command that performs git fetch followed by git merge in one step**. It updates your local branch with changes from the remote. git fetch alone downloads the changes but does not integrate them. This gives you more control to inspect or rebase instead of merging. Prefer fetch + rebase or fetch + merge for more predictable control over changes and avoiding unintended merges.
34
Q: What is a detached HEAD in Git, and why does it matter?
A: **A detached HEAD means you are no longer working on a named branch, but on a specific commit**. **Any changes you make won't be saved to a branch unless you create one explicitly.** This is useful for reviewing past commits or building temporary changes, but dangerous if you forget to create a branch — you can lose changes when switching branches. To save work, run git checkout -b new-branch-name. NOT WORKING ON A BRANCH BUT ON A COMMIT
35
Q: What is the purpose of git cherry-pick, and when should it be used?
A: git cherry-pick copies a specific commit from one branch and applies it to another. This is useful for applying bug fixes to multiple release branches, or reusing commits without merging full branches. However, it can complicate history and cause duplicate commits if used too much. It's best for selective, isolated commits, not regular workflow.
36
Q: What is a squash merge, and what are its benefits?
A: **A squash merge combines all the commits from a feature branch into a single commit when merging to the main branch.** This makes the history cleaner and easier to read, especially when many small or intermediate commits exist. It's often used in projects that prefer a linear and meaningful commit history. The downside is that individual commit history from the branch is lost unless preserved elsewhere.
37
Q: What are Git remotes and how are they managed?
A: Remotes are connections to remote repositories (e.g., on GitHub, GitLab). They allow you to sync changes between your local and remote repo. git remote add origin adds a remote git remote -v shows all remotes git remote set-url changes the remote URL You can use multiple remotes (e.g., origin, upstream) for working with forks or multiple sources.
38
Q: What is the difference between reset, revert, and checkout?
A: reset changes the current branch's history (use with caution). revert creates a new commit that undoes the changes of a previous one, preserving history (safe for shared branches). checkout switches branches or restores files from a different commit. Use revert for undoing commits on shared branches, and reset only local
39
Q: How does Git handle large files, and what is Git LFS?
A: Git struggles with large binary files because it tracks every version. Git LFS (Large File Storage) is an extension that stores large files (e.g., images, videos) outside the main repository, replacing them with small pointers in Git. This keeps the repository size manageable and speeds up clone/fetch operations. You need to install Git LFS separately and track files via git lfs track. USING GIT LARGE FILES STORAGE
40
Q: What is a good branching strategy for a team?
A: Common strategies: Git Flow: Feature branches, release branches, hotfixes — great for structured releases. GitHub Flow: Short-lived feature branches, merged to main via pull requests — best for continuous deployment. Trunk-Based: Everyone commits to main, with short-lived branches — best for fast-moving, automated CI/CD environments. The right choice depends on your team's size, release frequency, and CI setup.
41
Q: What is a rebase conflict and how is it resolved?
A: A rebase conflict occurs when rebasing and Git can't auto-apply changes on top of the new base. You must resolve the conflict manually, then continue with git rebase --continue. If things go wrong, you can abort with git rebase --abort. Rebase conflicts are more common than merge conflicts because rebase re-applies each commit one by one.
42
Q: Why is it important to keep branches short-lived?
A: Short-lived branches: Reduce merge conflicts Make code reviews faster Encourage regular integration Prevent divergence from main This aligns well with CI/CD practices and increases team productivity.
43
Q: How can Git be used to recover lost commits?
A: Git keeps history through references and the reflog. If a commit is lost (e.g., after a reset), you can recover it using git reflog to find the commit hash and then git checkout or git branch recover . Git never deletes commits immediately — they're usually recoverable within a short time.
44
Q: What’s the purpose of git stash and when should you use it?
A: git stash temporarily saves uncommitted changes so you can switch branches or pull updates without committing. It's useful when you're mid-work but need to pause or test something else. You can later apply it with git stash apply or pop it with git stash pop.
45
4 got stages are
1. modified 2. unmodified 3. staged 4. commited