Local repositories are great, but the real collaboration happens when you connect to a remote like GitHub or GitLab.
Adding a Remote
git remote add origin https://github.com/username/repo.git
Pushing Your Code
Send your commits to the remote:
git push -u origin main
The -u flag sets up tracking, so future pushes only need git push.
Pulling Changes
Get updates from your team:
git pull origin main
The Complete Workflow
Here’s a typical day with Git:
git pull- Get latest changesgit checkout -b feature/my-task- Create feature branch- Work, commit, repeat
git push -u origin feature/my-task- Push your branch- Create a Pull Request on GitHub
- Merge after review
That’s it! You now know the fundamentals of Git. Practice these commands daily and they’ll become second nature.