Remote Repositories – GitHub Integration

Remote Repositories – GitHub Integration

What is GitHub?

GitHub is a cloud-based platform that hosts Git repositories.

Connect Local Repo to GitHub

git remote add origin https://github.com/username/repo.git

Push Code

git push -u origin main

Pull Code

git pull origin main

Clone Repository

git clone https://github.com/username/repo.git

Git Fetch vs Pull

  • fetch → Downloads changes

  • pull → Fetch + Merge

Git Rebase

Reapply commits on top of another base branch.

git rebase main

Better for clean history.

Cherry Pick

Apply specific commit:

git cherry-pick commit_id

Git Stash

Temporarily save changes:

git stash
git stash pop

Interactive Rebase

git rebase -i HEAD~3

Used for:

  • Squash commits

  • Edit commit messages

  • Clean history

1️⃣ Write Meaningful Commit Messages

Bad:

fix

Good:

Fix authentication bug in login API

2️⃣ Use Feature Branches

  • main → stable

  • develop → integration

  • feature/* → new features

3️⃣ Pull Before Push

git pull origin main

4️⃣ Never Commit Secrets

Use .gitignore

Example:

.env
__pycache__/

5️⃣ Small & Frequent Commits

Improves:

  • Code review

  • Rollback safety

  • Debugging

Mastering Git makes you:

  • A better collaborator

  • A confident developer

  • Production-ready

For backend developers (like Django developers), Git is as important as:

  • Python

  • REST APIs

  • Databases


Comments

Popular posts from this blog

Database Integration in FastAPI (SQLAlchemy CRUD)

Middleware & CORS in FastAPI

Python Data Handling