What is GitHub?
- A platform for version control and collaboration
- It allows you and others to work on projects from anywhere
Setting Up GitHub
- Go to GitHub.com
- Click on
Sign Up
- Fill in your details and click
Create account
Creating a New Repository
- After logging in, click on
New repository
- Name your repository
- Choose to make the repository
Public
or Private
- Make sure the default branch name is
main
- Click
Create repository
Cloning a Repository
- Navigate to the main page of the repository
- Click
Code
- To clone the repository using HTTPS, under “Clone with HTTPS”, click the clipboard icon
- Open Git Bash
- Change the current working directory to the location where you want the cloned directory
- Type
git clone
, and then paste the URL you copied earlier - Press
Enter
to create your local clone
Making Changes
- Navigate to the file in your repository that you want to change
- Click the pencil icon in the upper right corner of the file view to edit
- Make and commit your changes
Creating a .gitignore File
- In your repository, create a new file named
.gitignore
- For a Node.js project, you might include the following in your
.gitignore
:
node_modules/
npm-debug.log
.DS_Store
.env
About .env and .gitignore
.env
files usually contain sensitive information like API keys and should not be tracked in Git- Including
.env
in your .gitignore
ensures it won’t be committed to your GitHub repository - Instead, provide a
.env.example
file with the required keys and dummy values to guide others
Pushing Changes
- Open a terminal
- Navigate to your repository directory
- Type
git add .
to add all changes - Type
git commit -m "Your message"
to commit changes - Type
git push
to push changes to GitHub
Pulling Changes
- Open a terminal
- Navigate to your repository directory
- Type
git pull
to update your local repository with the latest changes
Issues
Issues are a great way to keep track of tasks, enhancements, and bugs for your projects
- Navigate to the main page of the repository
- Click
Issues
- Click
New issue
- Create a title and write a description for your issue
- Click
Submit new issue
Pull Requests
Pull requests let you tell others about changes you’ve pushed to a branch in a repository on GitHub
- Navigate to the main page of the repository
- Click
Pull requests
- Click
New pull request
- Select the branch you made changes to and the branch you want to merge changes
into
5. Review your changes and click Create pull request