Your PC does not rely on the cloud: the entire repository lives on disk
Unlike obsolete centralized systems (like SVN), Git is peer-to-peer. Your local clone holds the complete graph of commits, tags, and branches. Platforms like GitHub are simply remote repositories with a conventional alias: origin.
- ✓
git commit(instant, zero network latency) - ✓
git branch&git switch(sub-millisecond branch operations) - ✓
git log&git diff(full offline history queries) - ✓
git merge&git rebase(autonomous local integration)
Stores the authoritative canonical copy for the team. Synchronized strictly over network protocols (SSH or HTTPS).
git push: transferring your confirmed commits to the cloud
Running git commit saves changes on your computer. To share them with your team or back them up to GitHub, you run git push. This sends object packs and advances origin/main on the server.
The key difference: git fetch vs git pull
Many developers confuse these commands: git fetch is safe and non-intrusive (downloads objects and updates origin/main without touching your working tree). git pull is aggressive: it fetches and immediately merges into your current branch.
Commit C4 pushed by your teammate in cloud.
origin/main (ref): Points to C2
Working Tree (archivos): Points to C2 (Clean)
💡 Use git fetch when you want to review changes before blindly merging them.
Why we use git push -u origin main and what upstream does
The first time you push a branch, Git does not know which remote branch to link it to. The -u (--set-upstream) flag creates a permanent link in your local config. From then on, simply typing git push or git pull suffices.
[core]
repositoryformatversion = 0
[remote "origin"]
url = git@github.com:facundo/proyecto.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
remote = origin
merge = refs/heads/main Everything up-to-date
Branch 'main' set up to track remote branch 'main' from 'origin'.
Error: [rejected - non-fast-forward] and how to recover
If a teammate pushed changes to GitHub while you worked locally, your histories diverge. Git blocks your push to protect their code. The mandatory remedy is to pull, integrate, and push again.
! [rejected] main -> main (non-fast-forward)
error: failed to push some refs to 'github.com:org/repo.git'
hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. The 5-step daily synchronization ritual
Following this technical routine at the start and end of every development day prevents 95% of conflicts and divergence in software teams.
Pull changes before touching code
Start your day updating main with changes your team merged overnight.
git switch main
git pull Branch out with purpose
Never code directly on main. Isolate your work in a well-named feature branch.
git switch -c feat/user-auth Small and frequent commits
Do not pile 5 days of work in one giant commit. Make atomic, testable commits.
git add -p
git commit -m "feat(auth): validate token" Push with upstream tracking
Publish your branch to the remote repository configuring tracking with -u.
git push -u origin feat/user-auth Open Pull Request for peer review
On GitHub, open the PR against main, describe context, link the issue, and await CI/CD.