DEV Community

Cover image for Beginner's guide to GitHub
Panchami Thulupule
Panchami Thulupule

Posted on

Beginner's guide to GitHub

What is Git?

It is an open source version control software. Version control is a system that records changes to a file or set of files over time so that you can keep track of the activities you performed.

In Real life projects, multiple developers work in parallel. So they need a version control system like Git to make sure that there are no code conflicts between them.

Why do we need it?

  • Git makes it easy to contribute to open source projects:
    If you want to contribute to other's projects, you just fork(get
    a copy of) the project, make your changes, and then make a pull
    request to the project owner using GitHub's web interface. This
    way the project owner can look into your changes and include
    these changes in their project.

  • To track changes in your code:
    When multiple people work on a project, itโ€™s hard to keep track
    of the changes โ€” who changed what, when, and where those files
    are stored. GitHub takes care of this problem by keeping track
    of all the changes that have pushed to the repository.

  • To showcase your work:
    Are you someone who wants to attract recruiters? GitHub is the
    best tool you can rely on for this. You will have a higher
    chance of being recruited if you have maintained a good GitHub
    account.

Set up your GitHub account

  • Create a GitHub account:

  • Download and Install GitHub Desktop.

Git Repositories

A repository is a project that contains multiple files. This repository tracks all the changes made to files in your project, building a history over time.
You can do following actions with a repository.

alt text

  • Create a new repository locally: Create a local repository by filling all the details.

alt text

  • Clone your repository: Cloning a GitHub repository creates a local copy of the remote repository. This allows you to make all of your changes locally rather than directly in the source files of the original repository.

alt text

  • Create an existing repository: If you have already created a repository, you can select this option and add the existing repository.

alt text

Publishing the Repository

After creating a Repository, you can publish this repository to the GitHub web interface.

alt text

Git commits

Commits are like a snapshot of your work and the changes you have made. It creates a history of every commit you make. This helps in keeping track of the changes you made to the project.

alt text

Push your changes to the main branch

After committing to the changes you have made to the project, you need to push the changes to the main branch.

alt text

Create a new branch

If you want to make a new feature but you are worried about making changes to the main project and spoiling it while implementing the feature. This is where git branches come in.
Click on the New Branch --> Give a name to the branch --> Create Branch.

alt text

alt text

Create a Pull Request

If you want to contribute or collaborate with other projects, you need to follow these steps:

  • Find a project you want to contribute to
  • Fork it

alt text

  • Clone it to your local system
  • Make a new branch
  • Make your changes
  • Push it back to your repository
  • Click on the Compare button After you push the changes you have made to the project, go to your repository on GitHub web interface, click on the Compare button.

alt text

  • Click on Create pull request to open a new pull request

alt text

Happy learning๐Ÿ˜Š

Top comments (0)