DEV Community

Cover image for let's start git from basics
Ishfaq Maknoo
Ishfaq Maknoo

Posted on

let's start git from basics

What is git?

Well according to Wikipedia, git is software for tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development. Its goals include speed, data integrity, and support for distributed, non-linear workflows (thousands of parallel branches running on different systems),

Enough theory, let's start doing some practical stuff,

Step 01:- Visit https://github.com/login to log in or create a new account,

Step 02:- https://github.com/new to create a new repository, I have created one as todolist (if you already have created one, feel free to skip this step)

image

Note:- You can either make the repository publically accessible or keep it private,

Hit the create repository button, and you are all set...

Congratulations you have created a new repository on GitHub,

Step 03:- Time to commit your local changes (from your local machine to GitHub)

From your local machine open your favourite terminal, I am using windows I have PowerShell opened,

Navigate your repository,

image

git init (Initialized empty Git repository in your working directory)

git remote add origin(add new remote in my case it is, https://github.com/ishfaqmaknoo/todolist )

git status (displays the state of the working directory)

So far so good, now let's add few more commands to push our code from local to staging to the remote repository

image

git add . (adds all the files to staging area)

we can also add each file manually by doing
(git add main.js ) this will add only the main.js file to the staging area,

let's finally push our local changes to the remote repository

image

git commit -m (Takes the staged snapshot and commits it to the project history. Combined with git add, this defines the basic workflow for all Git users.)

git push origin master (You are ready to push your first commit to the remote repository. )

image

Congrats, we are done with the big picture...

Commands:- Get used to these basic commands,

git init
git status
git add .
git commit -m "commit message"
git push origin master

Top comments (0)