Initial Tasks:
✅ Install Git on your system: Git Installation
✅ Configure your Git username and email:
git config --global user.name "Your Name" git config --global user.email "your@email.com"
✅ Create a new folder and initialize a Git repository:
mkdir git-project && cd git-project git init
✅ Create two files (
index.html
,style.css
), add content, and commit:
touch index.html style.css git add . git commit -m "Initial commit"
✅ Modify
index.html
, check changes, and make another commit:
git status git diff git add index.html git commit -m "Updated index.html"
✅ Check commit history using:
git log --oneline
✅ Create a GitHub Repository, add a remote, and push:
git remote add origin https://github.com/yourusername/git-project.git git branch -M main git push -u origin main
LEARN:
Git Full Course Part 1 - Covers Installation, Key Concepts, Demo with GitHub - LINK TO VIDEO
Challenge 1: Fork and Clone an Open-Source Project
Goal: Learn how to fork and clone a repository from GitHub.
Steps:
Go to the GitHub repository: eks-auto-mode-workshop
Click the Fork button to create a copy under your account.
Clone the forked repository:
git clone https://github.com/YOUR_USERNAME/eks-auto-mode-workshop.git
Navigate into the repository:
cd eks-auto-mode-workshop
Verify remote repositories:
git remote -v
Challenge 2: Create a New Branch (feature-branch), Switch, and Commit Changes
Goal: Learn how to create and switch branches, and commit changes.
Steps:
Create a new branch and switch to it:
git checkout -b feature-branch
Create a new file and add content:
echo "This is a new feature" > feature.txt
Stage and commit the changes:
git add feature.txt git commit -m "Added feature.txt"
Challenge 3: Merge feature-branch into main and Push the Changes
Goal: Learn how to merge branches and push updates.
Steps:
Switch to the main branch:
git checkout main
Merge the feature-branch:
git merge feature-branch
Push changes to the remote repository:
git push origin main
Challenge 4: Use git reset or git revert to Undo a Commit
Goal: Understand commit undoing methods.
Steps:
Use
git log
to find the commit hash:git log --oneline
Undo last commit (soft reset):
git reset --soft HEAD~1
If you want to revert changes without losing history:
git revert HEAD
Challenge 5: Rebase feature-branch onto main
Goal: Learn the difference between merge and rebase.
Steps:
Switch to the feature branch:
git checkout feature-branch
Rebase onto main:
git rebase main
Push changes (if necessary, use force push):
git push origin feature-branch --force
Challenge 6: Create a PR on GitHub from a Feature Branch
Goal: Learn how to create a pull request.
Steps:
Push your feature branch to GitHub:
git push origin feature-branch
Go to your repository on GitHub and click Compare & pull request.
Add a description and submit the PR.
Challenge 7: Create Conflicting Changes in Different Branches and Resolve Them
Goal: Understand how to resolve merge conflicts.
Steps:
Make changes in the same file in both
main
andfeature-branch
.Try merging
feature-branch
intomain
:git checkout main git merge feature-branch
Resolve conflicts manually and commit the merge.
Challenge 8: Use git stash to Save and Restore Uncommitted Changes
Goal: Learn how to use stash.
Steps:
Stash uncommitted changes:
git stash
List stashes:
git stash list
Apply the most recent stash:
git stash apply
Challenge 9: Add Version Tags to Commits and Push Them
Goal: Learn how to tag commits.
Steps:
Tag the latest commit:
git tag -a v1.0 -m "Version 1.0"
Push the tag to the remote repository:
git push origin v1.0
Challenge 10: Use git commit --amend and git rebase -i to Edit Past Commits
Goal: Modify past commits.
Steps:
Modify the last commit message:
git commit --amend -m "Updated commit message"
Rebase interactively to edit multiple past commits:
git rebase -i HEAD~3
Modify commits as needed and save changes.
This completes all the Git challenges!