Starting With Git and GitHub

Akash Srivastava
3 min readFeb 3, 2022

Hey beginners , Looking to start working on github contribute to a project you like or want to expand your knowledge 😉 , But want to learn it fast and easy So lets start ,

How to Create a Repo on GitHub ?

1 .Go to your Github profile

2 . Click on New Repository (marked in green)

3. Give a name to it (Data_Structures) or anything you like

4. Go Down below in page choose public or private . Public means other can see and work on it , private are the ones owned by you.

5. Hit create Repository and hurrah🎈 you did it.

ps : What is a repository in very simple terms consider it a big giant folder which will have all other files and folder

How to push my code files/Project from VSCode or from my system ?

First install git , https://git-scm.com/downloads then open git bash.

follow this procedure , Note * This procedure is also written when you create a new respository on github ,
git init
git add . //To add all the files in the folder
git commit -m ‘first commit’ //-m tells you the message that has to be put
git remote add origin <Remote repository url>

Some basic command to try out →

  • ls -a is a command you can use on git bash to view all hiden files in a folder
  • touch ‘filename.txt’ to create new file in a folder using git

git status // gives us the untracked files which are not added to our repo and not commited yet

  • git add name.txt to add a particular file to your repository not all
    vi name.txt to do some changes in the files right from bash

git clone to clone a repo from github to your desktop

  • git restore — staged names.txt to not commit or not stage the change
    git log to see history of changes
  • git fetch — all — prune this command will fetch all changes that had happended to main branch //prune are the ones that are deleted will also be fetched.

git pull upstream will also do the same thing.

git reset — hard upstream/master this will reset main or master branch of your origin to main or master branch of upstream .

If the GitHub repo has seen new commits pushed to it, while you were working locally, I would advise using:

git pull — rebase origin main

And last thing that you need to go is → How to merge code from your new branch to main Branch from where you forked ?

Firstly you need to push the changes or commit to your forked copy or the origin and as you do so , When you will go to your forked github repo you will se an option for create pull request to merge click on it and thats it , If the owner of the repo merges then it your code get merged to main branch.

This article became a little tricky 😐 but what I always do Increase the learning Curve😉 if you want to learn better and fast You will definately thanks me later if you read it carefully ,

Do Follow for more , peace ✌

--

--

Akash Srivastava

Android developer | Flutter | Dreamer | Part of Google developers Student Club | Advisor | Chess player | 😎