DEV Community

Cover image for This will remove Your GitHub Fear
Sanjay Singh Rajpoot
Sanjay Singh Rajpoot

Posted on

This will remove Your GitHub Fear

I have seen a lot of people facing problem using Git and GitHub properly😢, with the help of this guide most of your problems will be sorted🙂.

Why you should learn Git and Github 😕?

Before starting you should know why this is important. Open-source software is a huge part of the tech industry. Over and over, we hear about the power of open source. Git and GitHub is the backbone of open source community, everything from Readme file to fixing bugs starts and ends with GitHub. Let's start by discussing why you should be interested in getting involved with open source.

There are many benefits of contributing to open source projects. Assess your career and development goals and you might be able to accomplish them by contributing to open source software. Here's a brief and non-exhaustive list of some of the benefits of getting involved with open source:

-Familiarize yourself with Git
-Gain experience
-Get attention from employers and recruiters
-Connect with other developers in the community

Learn Git and GitHub Basics

Before you can go scouting for an open-source project to work on, you should know the basics of Git and GitHub. You don't need to be an expert. But there are a few commands you should definitely know and understand:

  • git init -> to start git
  • git clone
  • git checkout -b
  • git branch
  • git add
  • git commit -m -> commit with message
  • git merge
  • git push
  • git pull

This article won't discuss what these commands do or how they work. This is a checklist for you to measure your understanding. To make sure you understand when and how to use each command, I suggest you create your own project locally using Git and push your project to GitHub.

Now It's to time make your own Repository

Go ahead and log in with your email and password to GitHub. We are going to make our own repository so if anything gets wrong you can simply delete it and make a new one.

1. Go to GitHub.com

  1. In the upper-right corner of any page, use the drop-down menu, and select New repository.
    image

  2. Drop-down with option to create a new repository
    image

  3. Type a short, memorable name for your repository. For example, "hello-world".

  4. Field for entering a repository name
    Optionally, add a description of your repository. For example, "My first repository on GitHub."

  5. Field for entering a repository description
    Choose a repository visibility. For more information, see "About repository visibility."

  6. Select Initialize this repository with a README.
    image

  7. Initialize this repository with a README checkbox
    Click Create repository.

  8. Button to create a repository
    image

Congratulations! You've successfully created your first repository.

2. Clone your fork

To clone the fork you've created, click the "Code" button and copy the URL that's provided.

In your terminal, change into the directory that you want to hold your forked project

cd <directory_name>
Enter fullscreen mode Exit fullscreen mode

Now clone your forked repository using git clone and the URL you just copied

git clone <URL>
Enter fullscreen mode Exit fullscreen mode

Change into the folder that was just created. This will likely match the name of the project you forked. So if we're using the Sandpack repo as an example, that would be [sandpack]:

cd <project_name>
Enter fullscreen mode Exit fullscreen mode

3. Create a branch locally

Before you start working, create a separate branch that will hold all the code that you add or edit.

git checkout -b <branch-name>
Enter fullscreen mode Exit fullscreen mode

4. Make your changes

Now you can finally code! You may also be editing copy, fixing grammatical errors, or improving documentation. Whatever changes you're looking to make, you can finally do it at this step!

5. Commit and push your changes

Before you commit and push your changes, make sure to run and test your code. Once your sure that your code is functioning as desired, you can commit and push your changes to GitHub.

git add .
git commit -m 'commit message here'
git push -u origin head
Enter fullscreen mode Exit fullscreen mode

Congrates You made it 🥳🥳🎈🎉🎊

If you have followed all the steps properly everything should work fine. To check everything worked go to your GitHub repository and you will find all your changes.

Top comments (1)

Collapse
 
sanjaysinghrajpoot profile image
Sanjay Singh Rajpoot

Please suggest any changes 😀