Skip to main content

Command Palette

Search for a command to run...

๐Ÿš€ Git Practice Project

Updated
โ€ข5 min read

Understood โ€” here is the combined full text of both assignments in a clean printable format.

You can now copy it to Word, Google Docs, or continue formatting.


๐Ÿ“˜ Combined Assignment

Practice Project: Git Version Control and GitHub Collaboration


Project Name:

Student Profile Web Application Using Git and GitHub


Assignment 1: Git Version Control End to End


1. Introduction to Git

Git is a distributed version control system that stores full project history on every machine. It tracks changes using snapshots rather than storing file differences, making it efficient and scalable.

Centralized vs Distributed

FeatureCentralized VCSDistributed (Git)
Server required to workYesNo
Full local historyNoYes
Branching supportLimitedAdvanced
PerformanceSlowerFaster

2. Important Git Terminology

TermMeaningLocation Internally
RepositoryTracks project filesStored in .git
Working DirectoryYour active project filesSystem storage
Staging AreaTemporary holding before commit.git/index
CommitSnapshot of projectSHA generated object
BranchPointer to commit history.git/refs/heads
HEADCurrent working branch pointer.git/HEAD

3. Git Object Model

Git stores everything as four object types:

ObjectPurpose
BlobStores file content
TreeStores directory structure
CommitStores author metadata and parent commit
TagNamed reference to commit

All objects are hashed using SHA1 ensuring integrity.


4. Project Setup

mkdir student-profile
cd student-profile
git init
echo "<h1>Student Profile</h1>" > index.html
git add index.html
git commit -m "Initial commit: Add profile header"

Inspect storage:

git cat-file -p HEAD

5. Branching

git branch add-bio
git checkout add-bio
echo "<p>Name: Divyanshu Maurya</p>" >> index.html
git add index.html
git commit -m "Add student bio"

Compare:

git diff main..add-bio

6. Using Git Diff

git diff
git add index.html
git diff --cached

7. Merge and Rebase

Merge branch:

git checkout main
git merge add-bio

Rebase example:

git checkout -b add-skills
echo "<li>Web Development</li>" >> skills.html
git add .
git commit -m "Add skills section"
git rebase main

8. Git Stash

echo "<footer>Contact</footer>" >> index.html
git stash save "Footer WIP"
git checkout main
git stash pop

9. Cherry-Pick

git checkout -b fix-contact
echo "<p>Email Updated</p>" >> index.html
git commit -am "Fix email"
git checkout main
git cherry-pick <commit-id>

10. Create Tags

git tag -a v1.0 -m "First release"
git push origin --tags

11. Squash Commits

git rebase -i HEAD~3

12. Merge Conflict Handling

Conflict markers look like:

<<<<<<< HEAD
Version A
=======
Version B
>>>>>>> branch-name

Fix manually and commit.


13. Revert

git revert <commit-id>

Revert creates a new commit instead of altering history.



Assignment 2: GitHub Remote Collaboration


1. Introduction to GitHub

GitHub is a cloud platform for hosting Git repositories. It supports collaboration, issues, pull requests, automation, and team workflows.


2. Create Remote Repository

Create a new GitHub repo named:

student-profile-github

3. Connect Local Repo to GitHub

git remote add origin https://github.com/<username>/student-profile-github.git
git branch -M main
git push -u origin main

4. Clone Repository

git clone https://github.com/<username>/student-profile-github.git

5. Update README

echo "## Student Profile Project" > README.md
git add README.md
git commit -m "Add README"
git push

6. Create Pull Request

git checkout -b add-photo
echo "<img src='profile.jpg'>" >> index.html
git commit -am "Add photo"
git push origin add-photo

Then open a Pull Request on GitHub.


7. Merge Methods

MethodUse Case
Merge CommitPreserve full history
Squash MergeCombine commits for clean history
Rebase + MergeOrganizes history into linear path

8. Issues and Project Board

Create tasks like:

  • Improve UI

  • Add new form

  • Refactor layout

Assign and track inside GitHub Project Board.


9. Forking, Starring, Watching

  • Fork: Copy project to modify independently.

  • Star: Bookmark for future reference.

  • Watch: Receive update notifications.


10. Add Collaborator

Settings โ†’ Manage Access โ†’ Add Collaborator


11. GitHub Actions

Create folder:

mkdir -p .github/workflows

Basic workflow file:

name: CI Workflow

Commit and push.


12. Releases and Versioning

git tag v1.0
git push origin v1.0

Create detailed changelog in Release tab.


13. Backup and Archive

Use Download ZIP from GitHub for submission.



Final Submission Requirements

ItemRequired
ScreenshotsYes
Full CommandsYes
Project Folder StructureYes
Git History GraphYes
GitHub LinkOptional
Release and Pull Request ProofYes