Sign in
Log inSign up

5 easy steps to getting started with GitHub

Adarsh Patel's photo
Adarsh Patel
·Sep 21, 2021·

5 min read

5 easy steps to getting started with GitHub

Hello, readers Welcome to my second blog. If you are a developer then would already using some version control system like GitHub, Bitbucket, Phabricator, etc. But if you are not a developer or a beginner in development then probably you don't have much idea about these version control tools.

So in this article, We will look at the most popular version control system which is GITHUB.

What is GitHub?

If you can't explain it simply, you don't understand it well enough.

Albert Einstein

In simple words, it is like social media for developers it allows you to save, download, upload(push), share(collaborate) your code with other people (developers) like you. To do this, you must have an account on GitHub. You can create your GitHub account here github.com

github.png

After setting up your GitHub account you can create your first project using the following steps:

Step 1. Create a Repository

A repository is like a main folder where all files of your project like images, videos, code, etc are stored. We can also include the README file in our repository which contains information about the project.

How to create a new Repository

  1. In the upper right corner, next to your profile icon, click + then select New Repository.

  2. Name your first repository anything you want but always use a meaningful name.

  3. You can also add a description to your repository (not mandatory) as it is a good practice. In this, you can write what your project is all about. (optional)

  4. You can also set the visibility of your repository either Public or Private.

  5. Choose Initialize this repository with a README. It will add a README.md file into your repository.

  6. Click Create Repository

create repo.png

Congratulations🤩 You've successfully created your first repository on social media of Developers(GitHub).😎

Step 2. Create a Branch

In simple words, branching is like a vehicle is going on a highway which is considered as the main branch in Github. Suppose the driver wants to fuel his vehicle then he diverges from the highway to go to the petrol pump which is called a different branch other than main branch in Github. After the fuelling driver comes back to the highway which was the main branch.

So, Branching is the way of working on different versions of the current repository at the same time. By default, every repository has one branch named main. When we create a branch other than the main branch, we're making a copy of the main branch. If we made any change in the main branch while working with the newly created branch we can also get that change in our new branch by pull.

To create a new branch

branch.png

  1. Go to the newly created repository

  2. Click the drop-down at the top of the file list which is branch: main.

  3. Type a new branch name, into the new branch text box.

  4. Hit Enter on the keyboard.

🤩Congratulations!!! You've created a new branch. Now you've 2 branches, main and temp-branch.

Step 3. Make and commit changes

What is commits?

Have you ever played 🎮video games? If yes then you're familiar with checkpoints.

So commits in Github are nothing but checkpoints in our code. Every commit has a commit message, which is the description of the modification we made. Commit messages are helpful when anyone wants to know the history of changes.

Make and commit changes

commit in branch.png

Let's make some changes to our README.md file.

  1. Click the README.md file.

  2. Then click ✏ pencil icon in the upper right corner of the file view to edit.

  3. In the editor, make some changes by writing something about the project.

  4. After that write a good commit message which specifies your modification within the text area below the Commit Changes.

  5. Click the Commit Changes button or simply press the enter key on the keyboard.

WOW🤠 You've successfully committed.

One thing you should note here is that the above changes will be made to the README file on your new branch other than the main branch. So now this new branch contains contents that are different from main.

Step 4. Open a Pull Request

Now you are done with all the modifications in temp-branch. You have some new changes in temp-branch off of main branch. To add these new changes to the main branch, you have to open a pull request.

Pull Requests are the way of collaboration on GitHub. When you open a pull request, you're presenting your changes to other people on GitHub and requesting that they review and pull in your changes and merge them into their branch.

Pull requests show differences, in the content from both branches. The changes will be in form of additions and subtractions and shown in green and red respectively.

Open a Pull Request for changes to the README

new pull request.png

  • Click the Pull Request tab, then click the green New pull request button.

  • In the Example Comparisons box, select the temp-branch, to compare with main branch.

  • You can see changes in the diffs on the Compare page, make sure they’re what you want to submit.

create pul reqq.png

  • When you’re satisfied that these are the changes you want to submit, click the Create Pull Request button.

pull req added desc.png

  • You can give your pull request a suitable name along with a good description of all the changes you have done in temp-branch.

Step 5. Merge your Pull Request

Now, this is the last step. It's time to bring all your changes of temp-branch into main branch.

merge pull req.png

  • Click the green Merge pull request button to merge the changes into the main branch.

  • Click Confirm merge.

merge pull req and del.png

  • Now you can delete the branch with the Delete branch button in the purple box. Since its changes have been merged to the main branch.

It's time to celebrate 🤩 as you have learned

  • What is GITHUB
  • Create a Repository
  • Create a Branch
  • Make a Commit
  • Open a Pull Request

I hope you enjoyed reading this post as much as I enjoyed writing it, I’d be very grateful if you’d ♥ it & share it with your developer friend👨🏽‍💻, or sharing it on Twitter or Facebook. Thank you! Keep Learning and keep coding. 🤠