Course: Introduction to Git
Introduction to Git Git is a distributed version control system designed to track changes in files and coordinate work among multiple developers. It stores snapshots of a project over time so teams can review, revert, or branch from any point in history. Using Git encourages frequent, small commits with descriptive messages, which makes debugging and collaboration more transparent. Branching in Git enables parallel development: feature branches keep new work isolated until it is ready to merge. Because each developer has a full local copy of the repository, Git supports offline workflows and reduces single points of failure. Git’s merging and conflict-resolution tools help integrate contributions from different team members while preserving history. Remote hosting services like GitHub, GitLab, and Bitbucket add collaboration features—pull requests, CI/CD, and issue tracking—on top of basic Git functionality. Beginners start by installing Git, configuring their name and email, and initializing repositories with git init or cloning with git clone. The staging area (index) gives control over which changes become part of the next commit via git add. Committing with git commit records a snapshot and a message describing the change. Common daily operations include git status, git pull, and git push to synchronize work with remotes. Mastering these concepts early makes it far easier to adopt advanced workflows like rebasing, bisecting, and submodules later on.Lesson
Topic: Introduction to Git — fundamentals, workflow, and core commands
Learning Outcomes
- Understand what Git is and why it is used in software development.
- Describe the basic Git workflow: stage, commit, push, pull, and branch.
- Identify core Git terminology: repository, commit, branch, merge, clone, staging area.
- Run essential Git commands to initialize, inspect, and synchronize a repository.
- Apply simple branching and merging practices to isolate and integrate work safely.
Answer
After this lesson learners should be able to initialize a repository (git init), stage and commit files (git add / git commit), inspect status and history (git status, git log), and perform basic remote operations (git clone, git push, git pull).
Conceptual Explanation
Git is a distributed version control system that records a history of file snapshots (commits) and enables multiple developers to collaborate. Each clone contains the full project history so users can work offline and later synchronize changes with remote repositories. The staging area allows selective commits, which supports atomic and descriptive changes. Branches create isolated lines of development; merges combine those lines back into a main branch. Git stores objects (blobs, trees, commits) and uses SHA-1/ SHA-256 identifiers to reference commits, ensuring integrity of history.
Answer
Key ideas: repository = project + history; staging area = prepare commit; commit = snapshot + message; branch = independent timeline; merge = combine histories; clone/push/pull = sync between local and remote.
Bilingual (EN → বাংলা)
| English | Bangla (বাংলা) |
|---|---|
| Repository (Repo) | রিপোজিটরি (প্রকল্প সংরক্ষণস্থান) |
| Commit | কমিট (উপসংহার/স্ন্যাপশট) |
| Branch | ব্রাঞ্চ (শাখা) |
| Merge | মার্জ (একীভূত করা) |
| Clone | ক্লোন (স্থানীয় কপি তৈরি) |
| Staging Area | স্টেজিং এরিয়া (কমিট প্রস্তুতি) |
Answer
Use these translations to aid bilingual learners when explaining commands and concepts in Bengali. Example sentence: "git clone একটি রিপোজিটরি থেকে স্থানীয় কপি তৈরি করে।"
Important Notes
- Always configure your identity:
git config --global user.name "Name"andgit config --global user.email "email@example.com". - Write clear, concise commit messages that explain the “why” not just the “what.”
- Use branches for features and fixes; keep
mainormasterstable. - Pull before you push to reduce merge conflicts:
git pull --rebasecan help keep history linear for feature branches. - Never store large binary files directly in Git; use LFS or external storage if needed.
Answer
These practices reduce collaboration friction and keep repository history clean and useful.
Exercises
True / False
- Git is a centralized version control system.
- The staging area is required to commit changes.
- Branches in Git are cheap and fast to create.
Answer
False — Git is distributed; every clone has full history.
Answer
True — changes must be added to staging (via git add) or committed directly with some options before git commit.
Answer
True — branches are lightweight pointers to commits and are fast to create and switch.
Fill in the Blanks
- To create a new repository locally you run:
git ______. - To send your commits to a remote repository use:
git ______. - To view a condensed history of commits use:
git log --______.
Answer
init
Answer
push
Answer
oneline
Multiple Choice (MCQ)
- Which command shows the current status of files in your working directory?
- A.
git log - B.
git status - C.
git diff - D.
git branch
Answer
B.
git status— shows staged, unstaged, and untracked files. - A.
- Which operation creates a new local copy of a remote repository?
- A.
git init - B.
git clone - C.
git fetch - D.
git pull
Answer
B.
git clone. - A.
Matching
Match command → purpose
| Command | Purpose |
|---|---|
A: git add | 1: Create a new repository |
B: git commit | 2: Stage changes |
C: git init | 3: Record a snapshot with message |
Answer
Matches: A → 2 (git add stages changes), B → 3 (git commit records a snapshot), C → 1 (git init creates a repository).
Descriptive
Explain the difference between git pull and git fetch.
Answer
git fetch downloads commits and refs from the remote into your local repository but does not merge them into your current branch. git pull is shorthand for git fetch followed by a merge (or rebase depending on configuration), which updates your working branch with remote changes. Use git fetch when you want to review incoming changes before integrating them.
Creative
Design a simple branch-naming convention for a team and justify it.
Answer
Example convention: feature/-short-description, bugfix/-issue-number, hotfix/. Justification: prefixes make purpose and lifecycle clear; including initials helps identify owner; a short description or issue number links branches to tracking tools for traceability.
Activities
- Install Git and configure user.name and user.email on your machine.
- Initialize a local repository, create a file, stage it, and commit it.
- Push the repository to a GitHub or GitLab remote and clone it into another folder to verify.
Answer
Commands reference: git config --global user.name "Name", git config --global user.email "email", git init, touch README.md, git add README.md, git commit -m "Initial commit", git remote add origin <url>, git push -u origin main, git clone <url>.
Vocabulary
- Repository
- Commit
- Branch
- Merge
- Staging Area
- Remote
Answer
See the Bilingual table for translations and the Conceptual Explanation for concise definitions.
Homework
- Create a new public repository on GitHub with a README and a license, clone it locally, add a file, and push the change. Take screenshots of each step.
- Write a short reflection (200–300 words) about when to use branching and how it benefitted your workflow.
Answer
Submit the repository URL and your reflection. Instructor will check the commit history to verify steps were followed and that commit messages are descriptive.
Practice Task
Given a repository with a conflict after merging, list the steps you will take to resolve it and complete the merge.
Answer
- Run
git statusto identify conflicting files. - Open each conflicting file, locate conflict markers (
<<<<<<), and edit to the desired content. - After resolving, run
git add <file>for each resolved file. - Complete the merge with
git commit(Git may prefill a message). - Run tests and then
git pushto update the remote.
Quick Reference Table: Common Git Commands
| Command | Purpose | Example |
|---|---|---|
git init |
Initialize a new local repository | git init |
git clone |
Copy a remote repository locally | git clone https://github.com/user/repo.git |
git add |
Stage file(s) for commit | git add file.txt |
git commit -m |
Create a commit with message | git commit -m "Add feature" |
git status |
Show staged/unstaged/untracked files | git status |
git log |
View commit history | git log --oneline --graph |
git branch |
List or create branches | git branch feature-x |
git checkout / git switch |
Switch branches or restore files | git switch main |
git merge |
Merge another branch into current | git merge feature-x |
git push |
Send commits to remote | git push origin main |
git pull |
Fetch and integrate remote changes | git pull |
Answer
Use the example column as ready-to-run commands. Replace branch names and URLs with your project-specific values.
End of lesson — Next: Advanced Git workflows (rebasing, bisecting, submodules, CI integration).