- 1. Installing Git
- 2. What is Git?
- 3. Why is Git Important for Developers?
- 4. Terminal or Command Line Basics
- 5. What Are Branches?
- 6. Basic Git Commands
- 7. Git Branch Naming Conventions
- 8. Practicing Basic Git Commands
- 9. Merge Conflicts: What & Why
- 10. π₯ CHAOS MODE: Practicing Merge Conflicts
- 11. Bonus Topics
- 12. Resources
Create an account on Github.com. To install Git, please go to Git downloads.
Git is a version control system that tracks changes in your code and allows multiple people to collaborate on projects. It records what you did and when, so you can go back if needed.
Think of it like a save system for your code β with branching and multiplayer.
- π Track history: Revert to previous versions.
- π― Collaborate easily: Work with others without overwriting each other's code.
- π Industry standard: Used in nearly every professional software project.
- π Branching and merging: Test features without affecting the main project.
The Terminal is a simple, text-based way to talk to your computer. Instead of clicking buttons, you type commands to tell it what to do, like opening files, running programs, or using tools like Git.
- macOS: Use Spotlight β search "Terminal"
- Windows: Use Command Prompt, PowerShell, or Git Bash
- Linux: Press
Ctrl + Alt + T
| Command | Description |
|---|---|
pwd |
Print working directory path |
ls |
List files and directories |
cd |
Change directory |
mkdir |
Create a new directory |
touch |
Create a new empty file |
rm |
Remove a file or directory |
clear |
Clear the terminal screen |
cd folder_nameβ move into a foldercd ..β go back one directoryls -aβ list all files including hidden ones- Use
Tabto auto-complete file and folder names
nano filename.txtβ open file in Nano text editorvim filename.txtβ open file in Vim (advanced)code .β open current folder in VS Code (requires VS Code CLI installed)
Branches are like alternate timelines of your project.
They let you:
- Work on features independently from the main code.
- Experiment without breaking the live version.
- Collaborate by giving each developer their own "playground."
You're working on a website and want to add a "Contact Us" page. You can create a branch:
git checkout -b contact-pageNow you're working in a separate version of the project. You can make changes, commit them, and merge them back into the main branch when you're ready.
Create and switch to a new branch:
git checkout -b new-featureSwitch between branches:
git checkout mainList all branches:
git branchCopies a repository from a remote location to your local machine.
git clone https://github.com/example/repo.gitRetrieves updates from the remote repository but doesn't change your working files.
git fetchFetches changes and merges them into your current branch.
git pullStages changes (adds them to the "to be committed" list).
git add file.txt
# or all files
git add .Saves your staged changes with a message.
git commit -m "Added new feature"Sends your committed changes to the remote repository.
git pushShows the differences between files, commits, or branches.
See unstaged changes:
git diffSee staged changes:
git diff --stagedCompare two branches:
git diff main..feature-branchCompare specific files:
git diff filename.txtExample output:
- This line was removed
+ This line was added
This line stayed the sameGood branch names make collaboration easier and projects more organized!
Feature branches:
feature/user-authentication
feature/shopping-cart
feat/add-payment-integrationBug fixes:
bugfix/login-error
fix/header-alignment
hotfix/critical-security-patchExperiments:
experiment/new-ui-design
spike/performance-testingReleases:
release/v1.2.0
release/2024-spring-updateβ DO:
- Use lowercase letters
- Use hyphens to separate words
- Be descriptive but concise
- Include ticket numbers if you have them:
feature/PROJ-123-user-profile
β DON'T:
- Use spaces:
feature/new featureβ - Use special characters:
feature/new@featureβ - Make them too long:
feature/this-is-a-very-long-branch-name-that-describes-everythingβ
Create a GitHub repository and clone it locally:
git clone https://github.com/YOUR_USERNAME/git-practice.git
cd git-practiceCreate a new file: hello.txt
echo "Hello Git!" > hello.txtStage, commit, and push:
git add hello.txt
git commit -m "Add hello.txt"
git pushA merge conflict happens when Git can't automatically merge changes. This usually occurs when:
- Two people edit the same line of a file.
- A file is deleted in one branch and edited in another.
You'll see conflict markers in the file:
<<<<<<< HEAD
This is your change
=======
This is the incoming change
>>>>>>> branch-name
You must manually choose or combine the correct content, then stage and commit the file.
Time to embrace the chaos! We'll create some fun merge conflicts on purpose.
We'll create a collaborative story about our favorite "This is Fine" dog meme, where everyone contributes different versions of what's happening in the burning room.
- Follow instructor guidance to create branches and make changes
- Experience merge conflicts in a safe environment
- Learn to resolve conflicts step by step
- Practice using git diff to understand what changed
Your instructors will guide you through:
- Creating properly named branches
- Making conflicting changes to the same files
- Using
git diffto see what's different - Resolving conflicts when they occur
- Understanding conflict markers like:
<<<<<<< HEAD
Your changes
=======
Someone else's changes
>>>>>>> branch-name
- Conflicts are learning opportunities, not disasters!
- Take your time to understand what's happening
- Ask questions if you're unsure
- Every developer deals with merge conflicts regularly
Prevents tracking of certain files (e.g., log files, node_modules). You can add a .gitignore file to your code.
Discard local changes:
git checkout -- filenameUnstage files:
git reset HEAD filenameRevert commit:
git revert <commit-id>Stashing work: Save unfinished work without committing.
git stash
git stash popViewing history:
git logSee differences:
git diffWhat is a Fork? A fork is your own copy of someone else's repository on GitHub. Think of it like making a photocopy of a book so you can write notes in it without affecting the original.
Why do we fork?
- You want to contribute to someone else's project
- You don't have direct write access to the original repository
- You want to experiment with changes safely
- You want to use someone's project as a starting point for your own
How to fork:
- Go to the repository on GitHub
- Click the "Fork" button in the top-right corner
- GitHub creates a copy in your account
- Clone your forked version to work locally
git clone https://github.com/YOUR_USERNAME/forked-repo.gitGitHub Desktop is a graphical user interface (GUI) for Git that makes it easier for beginners to use Git without needing to type commands in the terminal.
- Clone repositories with a click
- View changes and commits visually
- Drag-and-drop file staging
- Resolve merge conflicts with an interface
How to Get Started: GitHub Desktop is a graphical user interface (GUI) for Git that makes it easier for beginners to use Git without needing to type commands in the terminal.
- Clone repositories with a click
- View changes and commits visually
- Drag-and-drop file staging
- Resolve merge conflicts with an interface
How to Get Started:
- Download: desktop.github.com (Available for macOS and Windows)
- Install and log in with your GitHub account
Conventional Commits is a specification for commit messages that makes them more readable and useful for automation.
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
feat:- A new featurefix:- A bug fixdocs:- Documentation only changesstyle:- Changes that don't affect code meaning (formatting, etc.)refactor:- Code change that neither fixes a bug nor adds a featuretest:- Adding missing testschore:- Changes to build process or auxiliary tools
git commit -m "feat: add user authentication"
git commit -m "fix: resolve login button alignment issue"
git commit -m "docs: update README with installation steps"
git commit -m "style: format code according to prettier rules"- Easier to read commit history
- Automatic changelog generation
- Easier to understand what changed
- Better collaboration in teams

