DEV Community

Cover image for Git And Github

Posted on • Updated on

Git And Github

Git is a version control system that lets you manage and keep track of your source code history.
GitHub is a cloud-based hosting service that lets you manage Git repositories
I never know that Git and github were two different words.
I started my journey of web development with React and realised that I need to know about Git and Github to manage my project.

I use Ubuntu.So, most of the commands I use here were related to Linux environment. I think except for installing every command was similar in other terminals also.

First things first lets install Git into our System.

$ sudo apt install git-all

after you check whether it is installed or not by running

$ git --version

you can install from here.

I did make a directory and navigated into it. To initialise the git into our directory we need to run

$ git init

it will create a folder .git

Lets start our work by adding stuff into the folder and then you need to commit your work.
commit is like a snapshot of your work.
First add the files to commit, you can add individual files

$ git add index.html

or all the files by

$ git add .

and then commit it with a message

$ git commit -m "😋 second Dev Post

> you can add multiple lines

> and whatever message you want"

We need a Remote Repository and we can create it by logging into our GitHub account and clicking the
+(New Repository)

we need to give Repository a name and then
Create repository and then add the remote branch to our local system by

$ git remote add origin <url to git repo>.git

and now we can push the code by

$ git branch -M main

All new Git repositories on Github uses main instead of master as default branch

After the brutal death of George Floyd and the Black Lives Matter protests earlier this year 2020, tech companies wanted to show their support for the black community by abandoning non-inclusive terms such as master, slave, blacklist, and whitelist Link

$ git push -u origin <branch>

Uff.. it is very unique experience writing a article and I know that I have some flaws and I need your support to make them right. I managed to write normal and basic command but I always feel confused during Pull and creating new branches and then merging them. But I will try to understand and write an article to continue from this. Thank you.

Top comments (2)

dnbln profile image
Dinu Blanovschi

$ git add remote <Repository name>

Should be git remote add origin <link to repo>.git

vasanth9 profile image

Thank you Dinu, updated the blog.