Version Control, Git, and GitHub Basics

Class: CSCE-313


Notes:

Remote Collaboration & GitHub

Question 1

On GitHub, what is the primary purpose of a "Fork" compared to a "Clone"?

Options:

Overall explanation:

Question 2

In a professional setting, why is it standard practice to use a Pull Request rather than pushing code directly to the main branch? List at least two benefits this provides to a software engineering team. **See … for more information.

Answer:

  1. A Pull Request allows teammates to review the code before it is merged into the main branch.
  2. The main branch is usually the production-ready version of the project.

Question 3

Why is it standard practice to run git pull before you begin a new session of coding on a shared repository, and what is actually happening "under the hood"?

Options:

Overall explanation:

Question 4

What is "Upstream" in the context of a forked repository?

Options:

Overall explanation:

Question 5

When using rsync for backups, which flag preserves permissions, ownership, and timestamps?

Options:

Overall explanation:

Conceptual Foundations

Question 6

Explain the fundamental difference between a Centralized Version Control System (like SVN) and a Distributed Version Control System (like Git). In your answer, describe what happens when a developer "clones" a repository in Git versus "checking out" a file in SVN. Answer it in a short essay. **See … for more information.

Answer:
The main difference between a Centralized Version Control System like SVN and a Distributed Version Control System like Git is the location of the project history.

With SVN, there's basically one central server that holds the entire repository. Developers connect to that server to get files and to commit changes. "checking out" a project in SVN means you're downloading the current version of the files, but the full history still mainly lives on the server. If the server goes down you are stuck in your local version. You also need to be connected to it to do any action.

With Git, it works differently. When you "clone" a repository, you're not just downloading the latest version of the files, you're copying the entire repository, including its full commit history, onto your own machine. That means your local copy is basically a complete version of the project including the project history, which also means you can do any git action like commit, branch, etc. without having to connect to the cloud.

Question 7

In Version Control, what is the primary purpose of a "Commit"?

Options:

Overall explanation:

Question 8

Beyond being a software tool, Git represents a "Distributed" philosophy of version control. Which of the following best describes the relationship between Git and a service like GitHub within this philosophy?

Options:

Overall explanation:

Question 9

What does the "Snapshots, not Differences" philosophy in Git mean? See … for more information.Links to an external site.

Options:

Overall explanation:

Question 10

Which of these best describes the "Three Trees" or "Three States" of Git?

Options:

Overall explanation:

Local Git Operations

Question 11

Which area in Git acts as a technical 'buffer' where changes are grouped before they are permanently recorded?

Options:

Overall explanation:

Question 12

When a developer runs the command git commit --amend to fix a typo in their most recent commit message, what is technically happening within the Git database?

Options:

Overall explanation:

Question 13

What does it mean when a Git repository is in a "Detached HEAD" state? **See … for more information.**Links to an external site.

Options:

Overall explanation:

Question 14

You have modified 5 files, but only want to include 2 of them in your next commit. How do you achieve this?

Options:

Overall explanation:

Question 15

What is the purpose of the .gitignore file?

Options:

Overall explanation:

Branching and Merging

Question 16

You have a feature branch that has fallen behind the main branch. You can integrate the new changes from main using either "git merge" or "git rebase".

  1. Describe the difference in the resulting commit history for both methods.
  2. Why might a project lead prefer the "rebase" workflow over "merge"?

Answer:
If you use git merge, Git creates a new merge commit that ties your feature branch together with main. The history keeps all the original branch structure, so it kind of looks like a tree with branches splitting and joining, and you can see which commits belonged to which branch.

If you use git rebase, Git basically moves your feature branch on top of the latest main commits. It rewrites all commits as if you started your work from the newest version of main. The history ends up looking clean and linear so you lose the branch commit structure and it looks like everything happened in a straight line.

Question 17

When a merge conflict occurs, Git marks the file with specific symbols. Identify what <<<<<<< HEAD, =======, and >>>>>>> [branch-name] signify.

Bonus: After you manually edit the file to resolve the conflict, what is the next Git command you must run to tell Git the conflict is resolved?

Answer:
When a merge conflict happens, Git can't automatically decide which changes to keep, so it marks the file with conflict indicators.

Here’s what the symbols mean:

<<<<<<< HEAD
=======
>>>>>>> branch-name

Visually:

<<<<<<< HEAD
your version
=======
their version
>>>>>>> feature-branch

Bonus Answer

Question 18

Why is it "best practice" to develop new features on a separate branch rather than the main branch?

Options:

Overall explanation:

Question 19

A developer uses git rebase -i HEAD~3 and changes pick to squash for the two most recent commits. What happens?

Options:

Overall explanation:

Question 20

What command would you use to see a list of all branches (both local and remote)?

Options:

Overall explanation: