Unit 11: Development Tools - Subjective Questions
CSE105 — Creative Engineering Workshop • Practice Questions with Detailed Answers
20 questions
Define Version Control and explain why it is essential in modern software development.
Version Control (also called Source Control) is a system that records changes made to a file or set of files over time so that specific versions can be recalled later.
Why it is essential:
- History Tracking: Every change is recorded with information about who made it, when, and why.
- Collaboration: Multiple developers can work on the same project simultaneously without overwriting each other's work.
- Reversibility: Enables reverting files or entire projects back to a previous state, undoing mistakes.
- Branching & Experimentation: Allows developers to experiment with new features in isolation without affecting stable code.
- Backup & Recovery: Acts as a distributed backup since every clone contains the full history.
- Accountability: Provides an audit trail useful for debugging and code reviews.
In short, version control brings safety, traceability, and teamwork to software projects, which is why tools like Git are indispensable.
Distinguish between Centralized Version Control Systems (CVCS) and Distributed Version Control Systems (DVCS) with suitable examples.
Centralized Version Control System (CVCS):
- Uses a single central server that stores all versions of the project files.
- Developers check out files from this central place and commit changes back to it.
- If the central server fails, collaboration and history may be lost.
- Examples: CVS, Subversion (SVN), Perforce.
Distributed Version Control System (DVCS):
- Every developer has a full local copy of the entire repository, including its complete history.
- Most operations (commit, log, diff) are local and fast, requiring no network.
- Highly fault-tolerant — any clone can restore the central repository.
- Examples: Git, Mercurial, Bazaar.
| Feature | CVCS | DVCS |
|---|---|---|
| Repository location | Central server only | Every developer's machine |
| Offline work | Limited | Full support |
| Speed | Network-dependent | Fast (local) |
| Fault tolerance | Low | High |
Conclusion: DVCS (like Git) is generally preferred today because of its speed, offline capability, and robustness.
Explain the three main states of a file in Git and how files move between them.
Git organizes files into three main states, corresponding to three areas of a Git project:
-
Modified (Working Directory):
- The file has been changed but the changes have not yet been recorded to the database.
-
Staged (Staging Area / Index):
- A modified file has been marked to go into the next commit snapshot.
- Achieved using
git add <file>.
-
Committed (Repository / .git directory):
- The data is safely stored in the local Git database.
- Achieved using
git commit.
Movement between states:
- Edit a file → it becomes Modified.
- Run
git add→ it becomes Staged. - Run
git commit→ it becomes Committed.
Working Directory --(git add)--> Staging Area --(git commit)--> Repository
Understanding these states is fundamental to controlling exactly what goes into each commit.
Describe the purpose of the git init command and what happens internally when it is executed.
Purpose of git init:
The git init command initializes a new Git repository in the current directory, turning an ordinary folder into a version-controlled project.
Syntax:
bash
git init
What happens internally:
- Git creates a hidden subdirectory named
.gitinside the project folder. - This
.gitdirectory contains all the necessary metadata and structures, including:objects/— stores all content (blobs, trees, commits).refs/— stores pointers to commits (branches, tags).HEAD— points to the current branch.config— repository-specific configuration.
- No files are tracked yet; you must use
git addto begin tracking.
Key Points:
- It is a one-time command per repository.
- It does not affect existing files; it only sets up the tracking infrastructure.
- To start with an existing remote project, use
git cloneinstead.
Explain the roles of git add, git commit, and git status with example commands.
These three commands form the core workflow of recording changes in Git.
1. git add
- Moves changes from the working directory to the staging area.
- Prepares selected files for the next commit.
bash
git add file.txt # stage a single file
git add . # stage all changes
2. git commit
- Permanently records the staged snapshot into the local repository.
- Each commit gets a unique SHA-1 hash and a message.
bash
git commit -m "Add login feature"
3. git status
- Displays the current state of the working directory and staging area.
- Shows which files are modified, staged, or untracked.
bash
git status
Typical Workflow:
git status # check what changed
git add . # stage changes
git commit -m "message" # record the snapshot
Together they let you inspect, stage, and save work in a controlled manner.
What is the purpose of git log? Describe some useful options/flags used with it.
Purpose of git log:
The git log command displays the commit history of a repository in reverse chronological order (most recent first). Each entry shows the commit hash, author, date, and message.
Basic usage:
bash
git log
Useful options/flags:
-
--oneline— Condenses each commit to a single line (short hash + message).
bash
git log --oneline -
--graph— Draws an ASCII graph of the branch/merge structure. -
--stat— Shows files changed and insertion/deletion counts. -
-p— Shows the full patch (diff) introduced in each commit. -
-n <number>— Limits output to the last n commits, e.g.git log -3. -
--author="name"— Filters commits by a specific author. -
--since/--until— Filters commits by date range.
Example (common combination):
bash
git log --oneline --graph --all
This command is invaluable for auditing history, debugging, and understanding project evolution.
Differentiate between Git and GitHub. Why are both commonly used together?
Git:
- A distributed version control system (software/tool).
- Installed locally on a developer's machine.
- Handles version tracking, branching, merging, and commit history.
- Works entirely offline.
GitHub:
- A web-based hosting platform (service) built around Git.
- Stores repositories in the cloud.
- Adds collaboration features: Pull Requests, Issues, code review, wikis, CI/CD (Actions).
- Requires an internet connection to sync.
| Aspect | Git | GitHub |
|---|---|---|
| Type | Tool/software | Hosting service |
| Location | Local | Cloud |
| Purpose | Version control | Collaboration & sharing |
| Network | Offline | Online |
Why used together:
- Git manages the local versioning, while GitHub provides a central place to share code, collaborate with teams, review changes, and back up repositories.
- Developers commit locally with Git and then push to GitHub for team access.
Analogy: Git is the engine; GitHub is the garage where the code is parked and shared.
Define a Repository in Git. Distinguish between a local repository and a remote repository.
Repository (Repo):
A repository is a data structure/storage location that contains all of a project's files along with the complete history of changes (commits, branches, tags). In Git, this history is stored inside the hidden .git directory.
Local Repository:
- Resides on the developer's own machine.
- Contains the full history and allows offline operations (commit, log, branch).
- Created via
git initorgit clone.
Remote Repository:
- Hosted on a server or cloud platform (e.g., GitHub, GitLab, Bitbucket).
- Acts as the shared central copy for team collaboration.
- Accessed using operations like
push,pull, andfetch.
| Feature | Local Repo | Remote Repo |
|---|---|---|
| Location | Developer's PC | Server/Cloud |
| Access | Offline | Requires network |
| Purpose | Individual work | Collaboration/backup |
Connection: A local repository is linked to a remote using a URL, commonly named origin.
Explain the git clone, git push, and git pull commands and their role in collaboration.
These commands synchronize work between local and remote repositories.
1. git clone
-
Creates a complete local copy of an existing remote repository (including all history and branches).
bash
git clone https://github.com/user/repo.git -
Used once when you first start working on an existing project.
2. git push
- Uploads local commits to the remote repository, sharing your work with the team.
bash
git push origin main
3. git pull
- Downloads and integrates changes from the remote into your local branch.
- It is effectively
git fetch+git merge.
bash
git pull origin main
Role in Collaboration:
- Clone → get the project.
- Pull → stay updated with teammates' changes.
- Push → share your own changes.
Remote Repo --clone/pull--> Local Repo --push--> Remote Repo
Together they keep everyone's copies in sync, preventing conflicts and data loss.
What is branching in Git? Explain its importance and the common commands used to work with branches.
Branching:
A branch is a lightweight, movable pointer to a commit that represents an independent line of development. The default branch is usually called main (or master).
Importance of Branching:
- Isolation: Develop new features or fix bugs without affecting the stable code.
- Parallel Development: Multiple team members work on separate branches simultaneously.
- Safe Experimentation: Try ideas that can be discarded without harming
main. - Organized Workflow: Supports strategies like feature branches, release branches, and hotfixes.
Common Commands:
git branch # list branches
git branch feature-x # create a new branch
git checkout feature-x # switch to a branch
git switch feature-x # modern way to switch
git checkout -b feature-x # create and switch in one step
git branch -d feature-x # delete a branchExample scenario: A developer creates feature-login, builds the login page there, tests it, and later merges it back into main once complete — keeping main always stable.
Explain the concept of merging in Git. Describe Fast-Forward and Three-Way merges. [10 Marks]
Merging:
Merging is the process of combining changes from one branch into another, integrating separate lines of development back together. It is typically done using:
bash
git merge <branch-name>
1. Fast-Forward Merge:
- Occurs when the target branch has not diverged — i.e., there are no new commits on the base branch since the feature branch was created.
- Git simply moves the branch pointer forward to the latest commit.
- No new merge commit is created.
Before: main -> A -> B
feature ------> C -> D
After (FF): main -> A -> B -> C -> D
2. Three-Way Merge:
- Occurs when both branches have new commits (histories have diverged).
- Git uses three commits: the two branch tips and their common ancestor.
-
Creates a new merge commit that has two parents.
A -> B -> C (main)
\
D -> E (feature)
Result: new merge commit M combining C and E
Merge Conflicts:
- Happen when the same lines are edited differently in both branches.
- Git marks conflicts with
<<<<<<<,=======,>>>>>>>markers, which must be resolved manually before committing.
Summary: Fast-forward is simple and linear; three-way merge preserves the true branching history via a merge commit.
What is a Pull Request (PR)? Describe the typical workflow of creating and reviewing a pull request on GitHub. [10 Marks]
Pull Request (PR):
A Pull Request is a feature on platforms like GitHub that lets a developer propose changes from one branch (or fork) to be merged into another branch. It is a request to "pull" your changes into the main codebase, and it serves as a hub for code review and discussion.
Typical Pull Request Workflow:
-
Create a Branch:
bash
git checkout -b feature-x -
Make Changes & Commit:
bash
git add .
git commit -m "Implement feature X" -
Push the Branch to Remote:
bash
git push origin feature-x -
Open a Pull Request on GitHub:
- Select the source branch (
feature-x) and target branch (main). - Add a title and description explaining the changes.
- Select the source branch (
-
Code Review:
- Teammates review the diff, leave comments, and request changes if needed.
- Automated CI checks/tests may run.
-
Address Feedback:
- Make additional commits and push again; the PR updates automatically.
-
Approval & Merge:
- Once approved, the PR is merged (merge commit, squash, or rebase).
-
Cleanup:
- Delete the feature branch after merging.
Benefits:
- Code Quality: Peer review catches bugs early.
- Collaboration: Central place for discussion.
- Traceability: Documents why changes were made.
- Controlled Integration: Protects the main branch from unreviewed code.
Compare the commands git fetch and git pull. When should each be used?
Both commands retrieve data from a remote repository, but they behave differently.
git fetch:
- Downloads new commits, branches, and tags from the remote.
- Does NOT modify your working directory or current branch.
- Updates only the remote-tracking branches (e.g.,
origin/main). - Lets you review changes before integrating them.
bash
git fetch origin
git pull:
- Performs a
git fetchfollowed by agit merge(or rebase). - Automatically integrates remote changes into your current branch.
- Modifies your working directory immediately.
bash
git pull origin main
| Aspect | git fetch | git pull |
|---|---|---|
| Downloads changes | Yes | Yes |
| Merges automatically | No | Yes |
| Working dir affected | No | Yes |
| Safety | Higher (review first) | Convenient but may cause conflicts |
When to use:
- Use
git fetchwhen you want to inspect remote changes before merging (safer). - Use
git pullwhen you want to quickly update your branch and are ready to integrate.
Describe the difference between the working directory, the staging area, and the repository using a practical example.
Git manages content across three conceptual areas. Consider editing a file named app.js.
1. Working Directory:
- The actual folder on disk where you edit files.
- Example: You open
app.jsand add a new function → the change lives here as unstaged.
2. Staging Area (Index):
- A preparation zone for the next commit.
- Example: You run
git add app.js, marking your changes to be included in the next snapshot.
3. Repository (.git):
- The permanent database of committed snapshots.
- Example: You run
git commit -m "Add function", saving the staged snapshot into history.
Flow Diagram:
[Edit app.js] [git add] [git commit]
Working Directory --> Staging Area --> Repository
(modified) (staged) (committed)
Key Insight: The staging area gives you fine-grained control — you can commit some changes while leaving others unstaged, creating clean, logical commits.
What are AI-Assisted CLI Tools? Explain their features and benefits in a developer's workflow. [10 Marks]
AI-Assisted CLI Tools:
These are command-line interface tools powered by Artificial Intelligence (typically Large Language Models) that help developers perform tasks directly from the terminal using natural language. Examples include GitHub Copilot CLI, Amazon Q / Kiro CLI, Warp AI, and Gemini CLI.
Key Features:
- Natural Language to Command: Translate plain English requests into shell/Git commands (e.g., "undo my last commit" →
git reset --soft HEAD~1). - Command Explanation: Explain what an unfamiliar command does before running it.
- Code Generation: Generate scripts, config files, and boilerplate code.
- Debugging Help: Analyze error messages and suggest fixes.
- Context Awareness: Read the current directory, files, and project structure to give relevant answers.
- Automation: Chain and execute multi-step tasks.
Benefits in Workflow:
- Increased Productivity: Less time spent memorizing complex syntax.
- Lower Learning Curve: Beginners can perform advanced operations safely.
- Fewer Errors: Explanations reduce accidental destructive commands.
- Faster Debugging: Instant suggestions for fixing issues.
- Focus on Logic: Developers concentrate on design and problem-solving rather than syntax.
Caution:
- Always review AI-suggested commands, especially destructive ones (e.g.,
rm -rf,git reset --hard). - AI can occasionally produce incorrect or outdated suggestions, so human verification remains essential.
Conclusion: AI-assisted CLI tools act as an intelligent pair-programmer in the terminal, boosting speed and confidence while requiring careful oversight.
Explain the purpose of the .gitignore file. Give examples of entries that are commonly ignored.
Purpose of .gitignore:
The .gitignore file tells Git which files and directories to intentionally ignore (i.e., not track). This keeps the repository clean by excluding files that are unnecessary, sensitive, or automatically generated.
Why it is important:
- Prevents committing temporary or build artifacts.
- Avoids exposing secrets/credentials (API keys, passwords).
- Reduces repository clutter and size.
- Avoids machine-specific files that cause conflicts.
Common entries with examples:
gitignore
Dependencies
node_modules/
vendor/
Build outputs
dist/
build/
.class
.o
Environment & secrets
.env
*.key
Logs
*.log
OS / IDE files
.DS_Store
.vscode/
.idea/
Key Points:
- Patterns support wildcards (
*), directories (/), and negation (!). .gitignoreonly affects untracked files; already-tracked files must be removed withgit rm --cached.- Should be created early in a project and committed to the repo.
What is a merge conflict in Git? Explain how it occurs and the steps to resolve it.
Merge Conflict:
A merge conflict occurs when Git is unable to automatically reconcile differences between two branches because the same part of the same file has been changed differently in each branch.
When it occurs:
- Two branches modify the same lines of a file.
- One branch deletes a file while another modifies it.
- Happens during
git merge,git pull, orgit rebase.
Conflict Markers in the file:
<<<<<<< HEAD
Your changes (current branch)
Incoming changes (other branch)
feature-branch
Steps to Resolve:
-
Identify conflicted files:
bash
git status -
Open each conflicted file and locate the conflict markers.
-
Edit the file to keep the correct code and remove the
<<<<<<<,=======,>>>>>>>markers. -
Stage the resolved file:
bash
git add resolved-file.txt -
Complete the merge with a commit:
bash
git commit
Tips:
- Use visual merge tools (VS Code,
git mergetool) for easier resolution. - Communicate with teammates to avoid overlapping edits.
- Pull frequently to minimize large conflicts.
Explain the significance of a commit message. Describe the characteristics of a good commit message.
Significance of a Commit Message:
A commit message is a short description attached to each commit explaining what changed and why. It is crucial because it forms the human-readable history of the project, aiding debugging, collaboration, and code reviews.
Why it matters:
- Helps teammates understand changes without reading all the code.
- Makes it easier to find and revert specific changes later.
- Improves traceability (linking commits to bugs/features).
Characteristics of a Good Commit Message:
- Concise Subject Line: Summarize in ~50 characters or less.
- Imperative Mood: Write as a command, e.g., "Add login validation" not "Added".
- Capitalized & No Trailing Period in the subject.
- Blank Line separating subject from body.
- Detailed Body (optional): Explains why the change was made and any context.
- Reference Issues: e.g.,
Fixes #42.
Example of a good message:
Add input validation to signup form
Prevents submission of empty email fields and shows an
inline error message. Resolves issue #57.
Poor example: "stuff", "fixed bug", "asdf" — these give no useful information.
Compare Merge and Rebase in Git. Discuss the advantages and disadvantages of each. [10 Marks]
Both merge and rebase integrate changes from one branch into another, but they do so differently and produce different history.
Git Merge:
- Combines branches by creating a new merge commit that ties the two histories together.
-
Preserves the complete history and the context of branching.
bash
git merge featureA---B---C (main)
\ \
D---E---M (merge commit)
Advantages:
- Non-destructive; original commits are unchanged.
- Accurately shows when and how branches came together.
Disadvantages:
- History can become cluttered with many merge commits.
- Log graph may be hard to read.
Git Rebase:
- Moves/replays the commits of one branch onto the tip of another, creating a linear history.
bash
git rebase main
Before: A---B---C (main)
\
D---E (feature)
After: A---B---C---D'---E' (feature, linear)
Advantages:
- Produces a clean, linear history.
- Easier to read and follow.
Disadvantages:
- Rewrites commit history (creates new commit hashes).
- Dangerous on shared/public branches — the golden rule: never rebase commits that others have based work on.
Comparison Table:
| Feature | Merge | Rebase |
|---|---|---|
| History | Preserved (non-linear) | Rewritten (linear) |
| Merge commit | Yes | No |
| Safety on shared branches | Safe | Risky |
| Readability | Cluttered | Clean |
Conclusion: Use merge for shared/public branches to preserve history; use rebase for cleaning up local commits before sharing.
Describe a complete end-to-end Git & GitHub workflow for a team member contributing a new feature to a project.
A typical feature contribution workflow using Git and GitHub involves the following steps:
1. Clone the Repository (first time only):
bash
git clone https://github.com/team/project.git
cd project
2. Update Local main Branch:
bash
git checkout main
git pull origin main
3. Create a Feature Branch:
bash
git checkout -b feature/user-profile
4. Make Changes and Stage Them:
bash
edit files...
git status # review changes
git add .
5. Commit the Changes:
bash
git commit -m "Add user profile page"
6. Push the Branch to GitHub:
bash
git push -u origin feature/user-profile
7. Open a Pull Request on GitHub:
- Compare
feature/user-profile→main. - Add title, description, and reviewers.
8. Code Review & CI:
- Teammates review; automated tests run.
- Address feedback with more commits if needed.
9. Merge the PR:
- Once approved, merge into
mainon GitHub.
10. Sync and Clean Up:
bash
git checkout main
git pull origin main
git branch -d feature/user-profile
Summary Flow:
clone -> pull -> branch -> edit -> add -> commit -> push -> PR -> review -> merge -> cleanup
This disciplined workflow keeps main stable, enables collaboration, and ensures every change is reviewed before integration.
Define Version Control and explain why it is essential in modern software development.
Version Control (also called Source Control) is a system that records changes made to a file or set of files over time so that specific versions can be recalled later.
Why it is essential:
- History Tracking: Every change is recorded with information about who made it, when, and why.
- Collaboration: Multiple developers can work on the same project simultaneously without overwriting each other's work.
- Reversibility: Enables reverting files or entire projects back to a previous state, undoing mistakes.
- Branching & Experimentation: Allows developers to experiment with new features in isolation without affecting stable code.
- Backup & Recovery: Acts as a distributed backup since every clone contains the full history.
- Accountability: Provides an audit trail useful for debugging and code reviews.
In short, version control brings safety, traceability, and teamwork to software projects, which is why tools like Git are indispensable.
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →