Welcome to GitHub! This guide will help you get started using GitHub, a platform for version control and collaboration. If you’re new to version control, GitHub is a great tool to manage and track changes to your code or files and work with others.
- What GitHub is and why it’s useful.
- How to create a GitHub account.
- Basic Git commands to work with GitHub.
- Creating your first repository.
- Making and tracking changes.
GitHub is a platform built around Git, a version control system that helps you manage changes to your codebase or documents. GitHub allows multiple people to work on a project at the same time and keeps track of each change.
- Version Tracking: Easily keep track of what changes were made and who made them.
- Backup: Store your work safely in the cloud.
- Collaboration: Work on projects with others efficiently.
- Go to GitHub.com.
- Click Sign up and create a free account.
- Complete the sign-up steps, and you’re ready to go!
Before using GitHub, you’ll need to install Git (if you haven’t yet):
Command | Description |
---|---|
git init |
Initializes a new Git repository in your folder |
git clone <url> |
Downloads a project from GitHub to your computer |
git add <file> |
Adds a file to the list of changes to be saved |
git commit -m "message" |
Saves your changes with a description of what you did |
git push |
Sends your changes to GitHub |
git pull |
Updates your local files with changes from GitHub |
Cloning a repository means downloading a copy of an existing project from GitHub to your local computer. This allows you to work on the project locally and keep it synchronized with the version on GitHub.
-
Find the repository you want to clone on GitHub.
-
Click the Code button on the repository's main page.
-
Copy the URL (you can choose HTTPS, SSH, or GitHub CLI, but HTTPS is usually easiest for beginners).
- For HTTPS, the URL will look something like this:
https://github.com/username/repository-name.git
- For HTTPS, the URL will look something like this:
-
Open a terminal (or Git Bash on Windows).
-
Navigate to the directory where you want to save the repository:
cd path/to/your/directory
-
Use the git clone command, followed by the repository URL:
git clone https://github.com/username/repository-name.git
-
Git will download the repository to your local machine. You can now enter the repository’s directory:
cd repository-name
A commit is a snapshot of your changes.
- After creating or cloning your repository and entering the project directory, you can create/add/modify any files
- Tell git to begin tracking this file with
git add <filename>
orgit add .
to track the entire directory - Commit your changes with a message
git commit -m "<message>"
- Push changes to GitHub
git push
If you’re working with others, you’ll want to keep your files up-to-date with changes they make.
- Use git pull to fetch and merge changes from GitHub:
git pull
- Add: Track files with
git add <file>
- Commit: Commit files with
git commit -m "<message>"
- Push: Send your changes to GitHub with
git push