DEV Community

Cover image for Getting Started: Git and Github for beginners with Hacktoberfest 2021
Muddhit Baid
Muddhit Baid

Posted on

Getting Started: Git and Github for beginners with Hacktoberfest 2021

At the stroke of the midnight hour, when the world sleeps, Programmers will awake to celebrate Hacktoberfest. A moment comes, which comes but once in a year, when we step in the Open Source Planet— when PR’s rain, when the swags wait for you

Beginning of the October, marks the beginning of Open source journey of a developer and the Hacktoberfest🎉.

For all the aspiring developers, this article is for you to start the contribution. We will be having look towards overview on Git & Github and also the steps to make you first PR.

P.S: PR → Pull request.

Git is a version control system used for collaboration and tracking software in the development process. It’s largely used from solo programmers to big tech giants.

Github, along with being a software for version control, feature tracking, hosting & lot more functionalities, its also a gigantic community for developers.

To get started:

  1. Create a Github account by signing up here.

  2. After signing up, you will land up to you account dashboard. After it, create a new Repository by navigating in the repositories tab, and click on the Create New button.
    New Repo Demo

  3. Now Download and install the latest version of git from here.

  4. After the installation is done, open the Terminal or Command Prompt and execute the following commands to configure your git setup.

git config --global user.name "<Enter your github username>"
git config --global user.email "<Enter your github email>"

You have successfully setup you git and github!! Yay🎉.
Now heading towards the PR.

First select the repository (Newbies don’t worry, i have handpicked some top repos for you at the end) which you want to work on and then open it. Finding good repositories might require some effort but whenever you’re looking a repo, Please firstly check if the Opened Issues(in Issues tab) can be solved by you or not. You can then comment inside a issue, asking the repository maintainers to assign it to you. After its assigned to you, Fork the repository by clicking on the fork button on the top right corner, this will fork and create a copy of original repo in your account.
Fork Demo

Click in the Code button and copy the url. I have taken one of my repository for the demo, you can also commit here.

Now execute the following command in your terminal( GIT BASH will be preferred, this comes along with the git) along with the copied URL.

git clone <COPIED_URL>

Eg: git clone https://github.com/Mukulbaid63/Hack-with-JavaScript

Successful clone message

The Above command clones the repository in the your local system.

Exexcute this command to go inside your repo.

cd <REPO_NAME>

At this point our commits will be going to the master branch but it’s advised to not commit in master branch, because the reviewers may review and then merge it , if it passes all the checks. So to create a new branch , execute the command below:

git checkout -b <NEW_BRANCH_NAME>

Let’s decode the above command -b creates a new branch and checkout switches the branch.

Now open the cloned folder in VS code(you can use any other code editors also). Now open the file which requires the changes. Complete all the requirements given in it and then save all the files.

After the issue is resolved and working on your local system, now its time to push it in the original repository.
Open Terminal and Follow the steps:

Execute the command to add all your changes to STAGING area.
git add .

If you want to commit only some files, then add the filename instead instead of .

  1. Now to commit the changes from STAGING area, execute the command below:

git commit -am "<COMMIT_MESSAGE>"
-m: Sets the commit message.
-a or — all: Commits all modified or deleted files.

  1. The last step will be to push the commits to the branch which you created initally.

git push origin <YOUR_BRANCH_NAME>

Successful Push

After successful push, you will see similar message as the above one. Now head towards the forked repo in Github. You will find some change there.
Pull request in Github

Similar row will appear after successful push, to create a PR , click on Compare & pull request . It will land you to the page shown below.
PR creation Page

By adding proper commit name and comments which can help your changes be clear to anyone other who opens your PR, you can now click on Create pull request. This creates the PR😀🎉. You can check the status on the Pull requests tab.
PR created

And that’s it. You have successfully created your first PR. Now , sit back and enjoy a cup of tea, as now your PR will be merged by the maintainer if it fulfills all the requirements. After its merged here, you can see the changes in the original repo also.

Get 4 PR’s merged in a month and here comes the Hacktoberfest swags for you!!!👏

If you’re struggling to find a Repository to work on, here are some top and handpicked repos by me, especially for beginners.

  1. https://github.com/praveenscience/FinalYear-Project-Ideas
  2. https://github.com/vinitshahdeo/Hacktoberfest2021
  3. https://github.com/HarshCasper/Rotten-Scripts
  4. https://github.com/AshuKulu/HacktoberFest2021
  5. https://github.com/Sushreesatarupa/DSA-cpp-Hacktoberfest2021
  6. https://github.com/aritraroy24/HACKTOBERFEST2021_PATTERN
  7. https://twitter.com/designerSaha/status/1443455576852217858

Resources:

  1. https://hf.praveen.science/ 👈🏻 Must check this🤩
  2. https://learngitbranching.js.org/(for better visualization)

Connect with me: Linkedin | Twitter

Top comments (0)