git help
💡 What is Git?
Git is a version control system (VCS). It helps you:
- Track every change in your code
- Revert to earlier versions if something breaks
- Work on the same files with your partner without conflicts
Think of it like a time machine for your project with superpowers for teamwork.
🛠️ Installing Git
Install Git on your device:
- Windows – Download Git
- Mac – use Terminal:
brew install git
- Linux – use Terminal:
sudo apt install git
🔧 Setting Up Git (One Time)
Open Terminal or Command Prompt and run:
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
🚀 Starting a Git Project
Option 1: Start a New Project
mkdir my-project
cd my-project
git init
Option 2: Clone an Existing Project
git clone https://github.com/username/project-name.git
cd project-name
🧩 Common Git Commands (With Explanations)
Command | Description |
---|---|
git status |
Check what's changed and what’s staged |
git add filename |
Stage a file (use . to stage all files) |
git commit -m "message" |
Save a snapshot with a message |
git log |
See the commit history |
git push |
Upload your commits to GitHub |
git pull |
Download the latest version from GitHub |
git branch |
List all branches |
git checkout branch-name |
Switch to another branch |
git merge branch-name |
Merge another branch into your current one |
🔁 Workflow Example for You and Your Partner
- Clone the repo (first time only):
git clone https://github.com/yourusername/project.git
- Make your changes
- Check what changed:
git status
- Stage your changes:
git add .
- Commit them:
git commit -m "Describe your changes"
- Push to GitHub:
git push
- Your partner pulls the latest code:
git pull
🧠 Git Tips for Newbies
- 💾 Commit often: Save your progress regularly.
- 📝 Use clear commit messages: Explain what and why.
- 🔄 Pull before push: Avoid conflicts.
- 🌿 Use branches for new features:
git checkout -b my-feature
🧑🤝🧑 Collaboration Tips
- Use GitHub for hosting your project.
- Add each other as collaborators on GitHub.
- Always
pull
before youpush
to avoid conflicts.
📚 Useful Resources
- Git Official Documentation
- GitHub Learning Lab
- Oh Shit, Git!?! – funny and helpful Git tips
Comments
Post a Comment