Github is a web-based platform that provides hosting for version control systems, allowing developers to collaborate on software development projects. It is a popular choice for managing code, tracking changes, and collaborating with other developers.
In this tutorial, we will go through the process of setting up and using Github for the first time.
- An internet connection
- A web browser
- An email address
- Basic knowledge of Git and version control concepts
Step 1: Create a Github account
To use Github, you first need to create an account. Go to https://github.com and click on the “Sign up” button in the top right corner of the page. Fill out the required information, including your email address, username, and password, and click “Create account.” Verify your email address by clicking on the link in the email Github sends you.
Step 2: Create a new repository
Once you have created an account and logged in, you can create a new repository by clicking on the green “New” button on the main page. Give your repository a name and a description, and choose whether to make it public or private. Click “Create repository” to create your new repository.
Step 3: Clone your repository
To start working on your repository locally, you need to clone it to your computer. In the repository page, click on the green “Code” button and copy the URL of your repository. Open your terminal and navigate to the directory where you want to clone your repository. Run the command: git clone <repository-url> to clone your repository.
Step 4: Make changes to your repository
After cloning your repository, you can start making changes to your code. Add, modify or delete files as needed. When you’re done making changes, run: git add . (don’t forget the period at the end) to stage your changes, and then run: git commit -m “commit message” to commit your changes.
Step 5: Push changes to Github
Once you’ve committed your changes locally, you need to push them to Github to make them available to other collaborators. Run the command: git push origin main to push your changes to the main branch of your repository on Github.
Step 6: Create a pull request
If you are working on a team, you may want to create a pull request to review and merge your changes into the main branch of the repository. To create a pull request, go to the repository page on Github, click on the “Pull requests” tab, and then click on the green “New pull request” button. Choose the branch that contains your changes and the branch you want to merge them into, and write a description of your changes. Click “Create pull request” to submit your pull request.
If you want to learn more about Git, then we highly recommend this free ebook: https://git-scm.com/book/.