Prateek Budhiraja
Prateek Budhiraja

Prateek Budhiraja

Beginner guide to Git and GitHub

Beginner guide to Git and GitHub

Prateek Budhiraja's photo
Prateek Budhiraja
·Jul 23, 2022·

2 min read

Subscribe to my newsletter and never miss my upcoming articles

Git is a distributed version control system. Using Git, many developers can make changes to the same code base at the same time without running into accidents like overriding someone else’s changes. Git will only update the differences made to a file.

Let's do a small demo to track and upload a simple markdown file to Github.

Git/Github Demo

  • First, go to your repositories and click new.

image.png

  • Fill in the repository name and description and click Create repository.

image.png

  • Go to your git bash terminal (and make sure that your git is already installed and configured, if not you can find links at the end of this blog.)

  • Traverse to the folder/directory where your file resides.

image.png

  • Now to track files on this directory, you need to initialize git onto your folder, use the below command to do that.
git init
  • You can also check the status of the files using.
git status

image.png

  • To start tracking a file (send to staging area) we use.
git add .

image.png

  • To save a version of that file we commit it with a message appropriate.
git commit -m "init commit"

image.png

  • Here we have the file tracked by git in our local system, but if we want our changes to reflect onto the cloud (Github in this case), we first get the URL where we want to store our code, which you will get from your new repo and we can set the branch of the repo.
git remote add origin git@github.com:prateek-budhiraja/resume.md.git
git branch -M main
  • Everything is set now, we can just push our code to GitHub with
git push -u origin main

image.png

  • Now when you refresh your repo, you will see your uploaded file.

image.png


Setup Github pages

You can go to the settings and then to Pages and do the below changes.

image.png

A couple of minutes after you save the settings, you will be able to access your Github pages website on the URL.

image.png

Resources 👇

Setup git with github

 
Share this