Lesson 1.4: Git and Github
When you work on a real project, you usually need to track different versions of the source code. Git is one of the most popular source control system. It allows users to track multiple versions of the source code locally for individual work, and multiple versions of the source code on the server for collaboration.
You can install git from the official website git-scm.com
Locally, Git repositories are stored in directories. On the server side, they are hosted in remote repositories. Most people use the server as the primary repository and the local repository for temporary changes while modifying the code they checked out from the server.
Basic Git commands you'll use frequently:
git clone <repository-url> # Clone a repository
git add <files> # Stage changes
git commit -m "message" # Commit changes
git push # Push changes to GitHub
git pull # Pull latest changes
Github is a web-based platform at github.com that hosts Git repositories and provides additional features for collaboration. It serves as a central hub where developers can:
- Store their code repositories
- Collaborate with other developers through pull requests and code reviews
- Track issues and bugs
- Manage project documentation
To get started with GitHub:
- Create an account at github.com
- Install GitHub CLI (gh) on your local machine. Follow the instructions in the GitHub CLI Quickstart Guide
- Configure Git with your GitHub credentials
- Create a new repository or clone an existing one
For more detailed information about Git and GitHub, visit the Git documentation and GitHub guides.