Course: Introduction to Git
Here is the requested composition followed by the lecture sheet in semantic HTML. Composition (13 sentences) Git is a distributed version control system that records changes to files and enables teams to collaborate efficiently. It allows every developer to keep a full copy of the repository history locally, which supports offline work and reliable backups. At its core, Git tracks snapshots called commits that capture the project's state at a specific moment, each annotated with a descriptive message. Repositories (repos) are the containers for those commits, organized into branches so parallel work can proceed without disrupting the main codebase. Branching and merging are central to Git’s workflow: branches isolate new features or fixes, and merge operations integrate those changes back into the main line. Developers stage changes to prepare and bundle logical updates before committing them, which helps keep the project history clean. Common remote operations—clone, push, and pull—allow synchronization between local copies and shared servers like GitHub or GitLab. Semantic and frequent commit messages, combined with atomic commits, make the version history easier to read and maintain. Tools such as git log, git diff, and GUI clients help visualize history and compare versions when debugging or reviewing. Beyond individual workflows, Git supports collaborative practices like pull requests, code reviews, and CI/CD integration. Installing Git and configuring a user name and email are the first steps to begin contributing. Learning Git’s basic commands and concepts provides a strong foundation for modern software development and teamwork. In subsequent lessons, we will explore branching strategies, conflict resolution, and advanced workflows to master collaborative development. Lecture sheet (semantic HTML)Lesson
Topic: Introduction to Git
Learning Outcomes
- Understand what Git is and why it is used in software development.
- Identify core Git concepts: repository, commit, branch, merge, clone, push, pull, staging.
- Perform basic Git operations: install, configure, init, add, commit.
- Explain the benefits of a distributed version control system and branching workflows.
Conceptual Explanation
Git is a distributed version control system (DVCS) designed to track changes to files over time. In Git, a repository stores project files and the full history of changes. Commits are snapshots of the project state recorded with messages to explain what changed and why. The staging area (index) lets you prepare and group related changes before committing them. Branches are lightweight pointers that enable parallel development; merges integrate branch work back into another branch. Remote repositories (for example on GitHub, GitLab, or Bitbucket) allow teams to share work; common remote commands are clone, push, and pull. A typical minimal local workflow is: git init → edit files → git add → git commit → git remote add → git push. Tools such as git log, git diff, and git blame help inspect history and diagnose issues. Good practices include frequent commits, clear messages, atomic changes, and using branches to isolate features or fixes.
Bilingual (EN → বাংলা)
EN: Git is a distributed version control system that lets multiple developers work on the same project while preserving a complete history of changes.
বাংলা: Git হল একটি বিতরণকৃত ভার্সন কন্ট্রোল সিস্টেম যা একাধিক ডেভেলপারকে একই প্রকল্পে একসঙ্গে কাজ করার সুযোগ দেয় এবং ফাইলগুলোর পরিবর্তনের সম্পূর্ণ ইতিহাস সংরক্ষণ করে।
Key terms / মূল শব্দাবলী:
- Repository (রিপোজিটরি): প্রকল্পের ফাইল ও ইতিহাস রাখার জায়গা।
- Commit (কমিট): নির্দিষ্ট সময়ের স্টেটের স্ন্যাপশট।
- Branch (ব্রাঞ্চ): সমান্তরাল ডেভেলপমেন্টের শাখা।
- Merge (মার্জ): শাখাগুলোর পরিবর্তন একত্রিত করা।
Important Notes
- Git is distributed: every clone contains the full history—this is different from centralized systems.
- Use descriptive commit messages: they make collaboration and debugging far easier.
- Stage selectively with git add to create logical, atomic commits.
- Always configure your git user.name and user.email before committing.
- Learn to resolve merge conflicts; they are a normal part of collaborative work.
Exercises
True / False
| Item | Statement | Answer |
|---|---|---|
| 1 | Git requires a continuous internet connection to make commits. |
AnswerFalse. Commits are local snapshots and can be made offline; pushing to remotes requires network access. |
| 2 | A branch in Git is a full copy of the repository files and history. |
AnswerFalse. A branch is a lightweight pointer to a commit; it does not duplicate the repository. |
Fill in the Blanks
- To create a new Git repository in the current directory you use:
git ______. - The command to stage a file called
app.pyisgit ______ app.py. - To send your local commits to the remote repository you use
git ______.
Answer
initAnswer
addAnswer
pushMultiple Choice Questions (MCQ)
| Q | Question | Options | Answer |
|---|---|---|---|
| 1 | Which command shows a condensed commit history? |
|
AnswerB: git log --oneline |
| 2 | Which Git operation brings changes from a remote to your local repo? |
|
AnswerC: pull |
Matching
Match the term (A–F) with the correct description (1–6).
| Term | Description |
|---|---|
| A. Commit | 1. A snapshot of file changes |
| B. Clone | 2. Create a local copy of a remote repo |
| C. Branch | 3. Pointer for parallel work |
| D. Push | 4. Send local commits to remote |
| E. Merge | 5. Combine changes from two branches |
| F. Staging area | 6. Buffer where you prepare files for commit |
Answer
A → 1, B → 2, C → 3, D → 4, E → 5, F → 6Descriptive
Explain in 3–4 sentences why branching is useful in Git.
Answer
Branching allows developers to isolate work on new features, bug fixes, or experiments without affecting the stable main branch. Each branch captures changes independently so that code can be reviewed, tested, and iterated before being merged. This reduces the risk of introducing instability and enables parallel development across a team. Branches also support workflows like feature branches, release branches, and hotfixes.Creative
Design a short branching strategy for a small team of 4 developers working in 2-week sprints.
Answer
Suggested strategy: use main as the stable production branch and create a develop branch for sprint integration. Each developer creates a feature branch named feature/ from develop. When features are ready, open pull requests into develop for review and CI tests. At the sprint end, merge develop into main and create a release tag (vYYYY.MM.DD). Use hotfix/ branches from main for urgent production fixes, then merge back into both main and develop.Activities
- Install Git and run
git --versionto verify. - Initialize a new repo, create a file, stage it, and commit.
- Clone a public repository and inspect its commit history with
git log --oneline --graph.
Answer
Follow-up hints: after git init, create README.md, rungit add README.md, then git commit -m "Initial commit". To clone: git clone https://github.com/USERNAME/REPO.git. Use git log --oneline --graph --decorate --all for a visual history.
Vocabulary
- Repository
- Commit
- Branch
- Merge
- Staging area
- Clone / Push / Pull
Answer
Short definitions: Repository—project storage; Commit—snapshot; Branch—parallel line of development; Merge—combine branches; Staging area—prepare changes; Clone—copy repo; Push—send commits; Pull—fetch and integrate.Homework
- Create a small repository with at least 5 commits that illustrate incremental changes to a file.
- Write a short (200–300 words) reflection about one merge conflict you could expect and how you would resolve it.
Answer
Deliverables: a GitHub (or other remote) link to the repo and a PDF or text file with your reflection. In the reflection, describe how to use git status, git diff, and a merge tool or git checkout --ours/theirs to resolve conflicting hunks, then commit the merged result.Practice Task
Using a sample project, create two branches, modify the same line in a file on both branches, and then merge one branch into the other to produce a conflict. Resolve the conflict and document the steps you took.
Answer
Steps: 1) git checkout -b branchA; edit file; git add & commit. 2) git checkout main; git checkout -b branchB; edit same line differently; commit. 3) git checkout branchA; git merge branchB → conflict occurs. 4) open conflicted file, edit to resolve, git add file, git commit. Use git log to show merge commit. Provide commands and screenshots if possible.Next lesson: Branching strategies, merge conflict resolution, and workflows (Gitflow, trunk-based, GitHub Flow).