DevOps Assignment 2 – Git & GitLab Operations
Name: Aditya Yevate
Roll No: A-63
✅ Objective:
To understand and perform essential Git operations using Git (locally) and
GitLab (remotely). This assignment aims to simulate real-world version control
workflows using branching, collaboration via fork/merge requests, history
rewriting, and cleanup.
🔧 Tools & Technologies Used:
Git – Distributed version control system
GitLab – Git repository hosting and DevOps platform
VS Code / Terminal / Git Bash – Local development tools
Operating System: Windows 10 / Ubuntu (any)
📝 Task-wise Report:
🔹 1. Create a Repository / Project
➤ On GitLab:
1. Login to https://gitlab.com.
2. Click on “New Project” > “Create Blank Project”.
3. Fill details:
o Project Name: devops-assignment
o Visibility Level: Public / Private (as required)
4. Click on Create Project.
➤ On Local Machine:
mkdir devops-assignment
cd devops-assignment
git init
➤ Link Remote Repository:
git remote add origin https://gitlab.com/<your-
username>/devops-assignment.git
🔹 2. Create Branches
Branches allow parallel development.
git branch feature-ui # Create new branch
git checkout feature-ui # Switch to that branch
OR in one step:
git checkout -b feature-backend
🔹 3. Perform Add, Commit, Push, Pull
➤ Add and Commit Changes:
echo "Welcome to DevOps Assignment" > index.txt
git add index.txt
git commit -m "Added index file"
➤ Push Changes to GitLab:
git push origin feature-ui
➤ Pull Latest Changes:
git pull origin main
🔹 4. Undo Commits
➤ Undo Last Commit (Keep Changes):
git reset --soft HEAD~1
➤ Undo Last Commit (Discard Changes):
git reset --hard HEAD~1
➤ Undo Git Add:
git reset HEAD index.txt
🔹 5. Fork a Project, Open and Merge Pull Request
➤ Forking a Repository:
1. Go to any public GitLab repository.
2. Click Fork and choose your namespace.
➤ Clone the Fork:
git clone https://gitlab.com/<your-username>/forked-
repo.git
cd forked-repo
➤ Make Changes & Push:
touch update.txt
git add .
git commit -m "Added update.txt"
git push origin main
➤ Create Merge Request:
Go to your forked repository.
Click Merge Requests > New Merge Request.
Choose source (your fork) and target (original).
Write description and submit.
🔹 6. Merge and Rebase
➤ Merging a Branch:
git checkout main
git merge feature-ui
➤ Rebase Feature Branch:
git checkout feature-backend
git rebase main
Rebase keeps a cleaner linear history.
🔹 7. Squashing Commits
Used to combine multiple commits into one.
➤ Command:
git rebase -i HEAD~3
Change the second and third lines from pick to squash.
Update commit message.
🔹 8. Delete Local & Remote Branches
➤ Delete Local Branch:
git branch -d feature-ui
➤ Delete Remote Branch:
git push origin --delete feature-ui