☁️ git commit is Local. git push is Remote.
Commit saves locally. Push uploads to remote repository. Share with team, backup, deploy.
📝 Basic Push
# Push current branch to origin remote git push # Push specific branch git push origin main # Push and set upstream (first time) git push -u origin main # Push all branches git push --all # Push tags git push --tags # Push specific tag git push origin v1.0.0 # Force push (overwrite remote - careful!) git push --force git push --force-with-lease # Safer force push
🎯 Push to Multiple Remotes
# Add multiple remotes git remote add github https://github.com/user/repo.git git remote add gitlab https://gitlab.com/user/repo.git # Push to both git push github main git push gitlab main # Push to all remotes at once git remote | xargs -L1 git push --all # Delete remote branch git push origin --delete feature-branch
💡 Common Issues
- Rejected push: git pull first, resolve conflicts, then push
- Force push: only for personal branches (never for shared branches)
- Authentication: configure SSH or personal access token
- Large files: use Git LFS
“git commit but forgot to push. Team didn’t see changes. Now always git push after commit. Push makes commits visible to everyone.”
