GitHub workflow

Git works fine on one laptop. GitHub adds the shared copy everyone pushes to, plus pull requests, reviews, issues and automation. The commands are few; the discipline is what matters.

Connecting a repository

git remote add origin https://github.com/you/project.git
git branch -M main
git push -u origin main      # -u links local main to origin/main
git remote -v                # check where origin points

origin is just the conventional nickname for the remote URL. For SSH remotes (git@github.com:you/project.git) add your public key under GitHub, Settings, SSH keys, so you stop typing passwords. For HTTPS, use a personal access token, not your account password.

The daily commands

Command What it does
git fetch Download new commits; change nothing locally
git pull fetch + merge into your current branch
git pull --rebase fetch + replay your commits on top; tidier history
git push Send your commits to the remote
git clone <url> Copy an existing repo, remote already set up

Start every working session with a pull and end it with a push. Most "Git nightmares" come from a week of local commits pushed at once.

The team flow

  1. git switch main && git pull to start from the latest code.
  2. git switch -c feature/invoice-pdf for your task.
  3. Commit in small steps.
  4. git push -u origin feature/invoice-pdf.
  5. Open a Pull Request on GitHub: describe what and why, link the issue.
  6. A teammate reviews; you push fixes to the same branch and the PR updates itself.
  7. Merge on GitHub, then delete the branch.
  8. Back on your machine: git switch main && git pull.
git switch main && git pull
git switch -c fix/gst-rounding
git commit -am "Round GST to two decimals"
git push -u origin fix/gst-rounding

Protect main under Settings, Branches so that it can only be changed through a reviewed pull request.

Fork or branch?

If you have write access to the repository, use a branch. For an open-source project you do not control, use a fork: your own copy on GitHub, from which you open a pull request back to the original.

Keep the repository clean

Add a .gitignore in the first commit for .env, __pycache__/, .venv/, db.sqlite3 and editor folders, and never commit secrets. A key pushed even once must be rotated, because deleting the commit does not remove it from clones and caches. A README.md explaining setup in five lines saves every new teammate an hour.

Common mistakes

  • Pushing to main instead of a branch, bypassing review.
  • Resolving "rejected: non-fast-forward" with git push --force on a shared branch.
  • Committing large files (exports, videos); the repo bloats permanently.
  • Opening a pull request with 40 files and the title "updates".

Practice

Create a repository on GitHub, push an existing local project to it, then make a change on a branch, push it and open a pull request with a short description. Ask a friend to clone the repo, push a change to main, and practise pulling their work before your next push.

B

Written by Bablu Kumar Jha

Founder, BeeProton AI · Mumbai, Maharashtra, India