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:


🔧 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

  1. Clone the repo (first time only):
    git clone https://github.com/yourusername/project.git
  2. Make your changes
  3. Check what changed:
    git status
  4. Stage your changes:
    git add .
  5. Commit them:
    git commit -m "Describe your changes"
  6. Push to GitHub:
    git push
  7. 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 you push to avoid conflicts.

📚 Useful Resources


Comments

Popular posts from this blog

Register a new device to Apple account

Type script for begginers