Exercise 1: Git & Github Practice Material
Objective: Learn to initialize repositories, add and commit files, and check status/history.
Exercises
- Create a folder called
git_practiceon your computer. - Initialize a Git repository inside it.
- Create a file called
notes.txtwith some content. - Stage and commit the file.
- Modify the file, then check Git status before committing.
- View commit history using
git log.
Commands to Practice:
git init
git status
git add notes.txt
git commit -m "Initial commit"
git log
2. Remote Repository Practice
Objective: Learn to connect local repositories to GitHub.
- Create a new GitHub repository called
git_practice_repo. - Connect your local
git_practicerepo to GitHub. - Push commits to GitHub.
- Create a new file
todo.txt, add some tasks, and commit. - Push the new commit to GitHub.
git remote add origin https://github.com/username/git_practice_repo.git
git branch -M main
git push -u origin main
git add todo.txt
git commit -m "Add tasks"
git push
3. Branching and Merging
Objective: Learn how to create branches, make changes, and merge them.
Exercises
- Create a branch called
feature-update - Add a new file
feature.txtwith content. - Commit your changes.
- Switch back to the
mainbranch and mergefeature-update. - Resolve any merge conflicts (optional: create conflicting changes in
feature.txtto practice resolving).
Commands to Practice:
git checkout -b feature-update
git add feature.txt
git commit -m "Add new feature"
git checkout main
git merge feature-update
4. Challenge Mini-Project
Objective: Apply Git & GitHub workflow in a small project.
Task:
Create a simple "Personal Notes Organizer" project:
- Folders structure:
notes/andarchive/ - Add a few text files with sample notes.
- Commit and push changes to GitHub.
- Create a
featurebranch to add an "Archive" feature. - Merge back to main after completing.