March 1, 2025
O. Wolfson
GitHub is a powerful platform for version control and collaboration, allowing developers to work together on projects efficiently. It builds on Git, a distributed version control system, by adding cloud-based repository hosting, issue tracking, pull requests, and more. Whether you're working solo or in a team, mastering GitHub ensures smooth project management, code sharing, and version tracking.
In short, Git manages versions locally, while GitHub makes collaboration possible by syncing changes across developers.
If your project is not yet a Git repository, run:
shgit init # Initializes a Git repository
git add . # Stages all files for commit
git commit -m "Initial commit" # Commits files to version history
Now, connect the local repo to GitHub:
shgit remote add origin https://github.com/your-username/repo-name.git
git branch -M main # Ensures you are on the main branch
git push -u origin main # Pushes the local project to GitHub
Your code is now hosted on GitHub!
If you want to download an existing project from GitHub, use:
shgit clone https://github.com/username/repository.git
This creates a local copy of the project, allowing you to work on it.
When collaborating with others, always pull the latest updates before making new changes:
shgit pull origin main
This ensures your local branch is in sync with GitHub.
git fetch vs. git pullgit fetch retrieves changes from the remote repository but doesn’t apply them.git pull fetches the changes and merges them into your local branch.Use git fetch if you want to review changes before merging, and git pull when you want to update immediately.
shcd path/to/your/project
shgit init
shgit add .
git commit -m "First commit"
shgit remote add origin https://github.com/your-username/repo-name.git git branch -M main git push -u origin main
shgit clone https://github.com/your-username/repo-name.git
shgit add .
git commit -m "Added new feature"
git push origin main
shgit pull origin main
Mastering GitHub allows for seamless collaboration, version tracking, and efficient teamwork. By understanding how to push, pull, and clone repositories, teams can work together on projects without code conflicts. Practicing these commands will help you integrate GitHub into your daily workflow for smoother project management.