EPEnglishPreps Log InFree Sign Up
Home › Academic Composition › Other Compositions

Course (Part 548)

Other Compositions · English · 15 Nov 2025

🎯 Other Compositions🌐 English📅 15 Nov 2025📖 Course 240 of 683
📚 All Other Compositions compositions
🧠 Test Your Skill10 questions from this composition
Other CompositionsCourse (Part 548)

Course: Intermediate Git

I. Composition (13 sentences) Working with branches is a core practice in modern version control systems, especially Git, that enables parallel development without destabilizing the main codebase. Branches act as pointers to commits and represent independent lines of development for features, fixes, or experiments. Creating a branch is quick and reversible, which encourages experimentation and reduces the risk associated with invasive changes. Switching between branches updates your working directory so you can focus on one task at a time while preserving other work. Merging integrates completed changes back into a target branch and may produce fast-forward or three-way merges depending on history. When merges conflict, tools and careful resolution are required to produce a coherent final state. After successful integration, deleting obsolete branches helps keep the repository organized and reduces cognitive load for collaborators. Naming conventions and small, focused branches improve readability and simplify reviews and merges. Regularly pulling and merging from the main branch into a feature branch reduces divergence and minimizes painful conflicts later. Pushing branches to a remote repository enables collaboration and serves as a backup for ongoing work. Pull requests and code reviews provide structured checkpoints before merging to ensure code quality and shared understanding. Practicing branch hygiene—clear names, focused scope, frequent commits—makes teams more productive and resilient. Mastery of branching and merging patterns is foundational for scalable, collaborative software development. II. Structured Lecture Sheet (semantic HTML only)

Lesson

Topic: Working with Branches — Introduction to Branches

Learning Outcomes

  • Understand what a branch is and why branches are used in Git.
  • Create, switch, list, merge, rename, and delete branches using command-line Git.
  • Recognize merge types and resolve simple merge conflicts.
  • Apply best practices for branch naming, scope, and remote collaboration.

Conceptual Explanation

A branch is a movable pointer to a commit that represents an independent line of development. Branching isolates work (features, bugfixes, experiments) from the main codebase; merging integrates those changes back. Typical flow: create a branch, switch to it, make commits, keep it up to date with main, open a pull request or merge locally, resolve conflicts if any, then delete the branch when done. Use short-lived, focused branches and descriptive names (e.g., feature/login, bugfix/issue-123).

Common Git Branch Commands
Action Command Purpose
Create branch
git branch <branch-name>
Create a new local branch pointer
Create & switch
git checkout -b <branch-name>
Create and immediately switch to the new branch
Switch branch
git checkout <branch-name>
Update working directory to branch state
List branches
git branch
git branch -a
Show local (and -a for all) branches
Merge
git checkout main
git merge <branch-name>
Integrate changes from another branch into current
Delete branch (local)
git branch -d <branch-name>
git branch -D <branch-name> (force)
Remove local branch (safe/force)
Rename local branch
git branch -m <old> <new>
git branch -m <new> (if on branch)
Rename branch
Count branches
git branch | wc -l
git branch -r | wc -l
Count local/remote branches (Unix)

Bilingual (EN → বাংলা)

Branch শাখা — রিপোজিটরির একটি স্বাধীন ডেভেলপমেন্ট লাইন যা একটি নির্দিষ্ট কমিট পয়েন্ট করে। Merge মার্জ — একটি শাখার পরিবর্তনগুলো অন্য শাখায় একত্রিত করা। Checkout চেকআউট — নির্দিষ্ট শাখায় সুইচ করে ওয়ার্কিং ডিরেক্টরির অবস্থা পরিবর্তন করা। Delete branch শাখা মুছে ফেলা — আর প্রয়োজন না হলে স্থানীয় বা রিমোট শাখা সরিয়ে ফেলা।

Important Notes

  • Always check your current branch with git branch before making changes.
  • Pull or merge from main into your feature branch frequently to reduce conflicts.
  • Use remote pushes (git push origin <branch>) and set upstream (--set-upstream) for collaboration.
  • Communicate renames and deletions with your team to avoid breaking workflows.

Exercises

True / False

  1. Creating a branch copies files to a new directory.
    AnswerFalse — creating a branch creates a pointer to a commit; files are not duplicated on disk until changes are made in the working tree.
  2. A fast-forward merge creates a new merge commit.
    AnswerFalse — fast-forward moves the branch pointer and does not create a merge commit.
  3. You must delete a branch before merging it.
    AnswerFalse — deletion is optional and typically done after successful merge.

Fill in the Blanks

  1. To create and switch to a branch in one command:
    Answer
    git checkout -b <branch-name>
  2. To see all remote branches use:
    Answer
    git branch -r
  3. To force-delete a local branch:
    Answer
    git branch -D <branch-name>

Multiple Choice (MCQ)

  1. Which command sets the upstream for a renamed local branch?
    • a) git push origin --delete <old>
    • b) git push --set-upstream origin <new>
    • c) git branch -m <old> <new>
    Answerb) git push --set-upstream origin <new>
  2. Which strategy is recommended to minimize merge conflicts?
    • a) Work in a single long-lived branch for everything
    • b) Regularly merge main into feature branches
    • c) Never pull from remote
    Answerb) Regularly merge main into feature branches

Matching

Match the command (A–E) with its effect (1–5):

Command Effect
A.
git branch -d feature
1. Delete remote branch
B.
git push origin --delete feature
2. Create and switch to branch
C.
git checkout -b feature
3. List all branches
D.
git branch -a
4. Delete local branch (safe)
E.
git branch -m old new
5. Rename a local branch
Answer

Matches: A→4, B→1, C→2, D→3, E→5

Descriptive

Explain the difference between a fast-forward merge and a three-way merge.

Answer

A fast-forward merge happens when the target branch has no new commits since the source branch split; Git simply moves the target pointer forward to the source tip without creating a merge commit. A three-way merge occurs when both branches have new commits since their common ancestor; Git creates a new merge commit that has both branch tips as parents and uses the common ancestor to compute differences.

Creative

Design a brief branching policy for a small team (3–6 developers) using feature branches and pull requests.

Answer
  1. All work on features/fixes must be done in short-lived feature branches named feature/... or bugfix/....
  2. Feature branches should rebase or merge main at least daily to stay current.
  3. Open a pull request for every branch; require one approving review and a passing CI build before merging.
  4. Use squash or merge commits consistently (team decision) and delete branches after merge.
  5. Hotfixes can be branched from main and merged back into both main and develop if applicable.

Activities, Vocabulary, Homework, Practice Task

Activities

  1. Pair exercise: create a feature branch, implement a small change, push it, and make a pull request.
    AnswerPartners should confirm branch creation (git checkout -b), push (git push -u origin <branch>), and open a PR on the remote platform.
  2. Conflict simulation: both students edit same line, then merge and resolve.
    AnswerOne student merges the other's branch and resolves the conflict markers, stages, and commits the resolution.

Vocabulary

BranchPointer to a commit representing a line of development. MergeOperation to combine changes from different branches. CheckoutSwitching working directory to a branch or commit. UpstreamRemote branch that local branch tracks for push/pull.
AnswerDefinitions above provide concise meanings; review them before practical tasks.

Homework

  1. Read the team's chosen branching strategy (Git Flow / Trunk-Based) and write 200 words on when you'd prefer one over the other.
    AnswerSubmit the write-up with examples: Git Flow for scheduled releases, Trunk-Based for continuous delivery.
  2. Create 3 branches locally, make commits on each, merge them into main and document commands used.
    AnswerProvide a short transcript of commands and outcomes (include any conflict resolutions).

Practice Task

Using a sample repo, demonstrate: clone → create branch → commit change → push → open PR → merge → delete branch. Record commands and results.

Answer

Expected command sequence (example):

git clone https://github.com/you/sample.git
cd sample
git checkout -b feature/example
# edit files
git add .
git commit -m "Add example"
git push -u origin feature/example
# open PR on GitHub, approve & merge
git checkout main
git pull origin main
git branch -d feature/example
git push origin --delete feature/example

Next lesson: Resolving merge conflicts and advanced merge strategies.

Similar compositions

🎓 Want more writing practice?Make academic composition sheets for any class, subject and chapter on AlphaGenEdu - free.
Create free account →