Basic Git Commands by@ysoni0303

Basic Git Commands

Yash Soni HackerNoon profile picture

Yash Soni

First, solve the problem. Then, write the code. All about JavaScript.

If you’re a Software developer, you cannot live without interacting with Git and it is never too late for anything!

So here are some very basic, yet very important Git commands which you will require in your daily life.

Git - Git is a distributed version control system for tracking changes in source code during software development while working on your local machine.

GitHub - Github is version-control distributed git platforms used for storing your code inside git repositories just like GitLab, BitBucket.

Let’s directly dive into commands & understand their usage:-

The workFlow of Git:

Write some code...

<p> Write some code... </p>

Store changes:

$git add .

Push changes:

$git push

Make a pull request:

$git pull

Commands for Git:

1. To check version

$git --version

2. Create a file in your project

$ touch index.html

3. Initialize it as a git repository

$git init

4. Add a file

$git add index.html
$git add .  /*adds files modified*/

5. To see the status of a file

$git status

6. Remove index.html

$ git rm --cached index.hmtl

7. Commit changes

$git commit -m ‘messages’

8. Create a new branch

$git branch branchName

9. Change branch

$git checkout branchName

10. Merge branch

$git merge branchName

The workFlow of GitHub & its commands:

WorkFlow - Write some code > Commit changes > Make a pull request

1. Create a new repository on your GitHub account
2. Copy the remote URL (
3. In your terminal write:
$ git remote

$ git remote

4. In your terminal write:

$git push -u origin master

Some Bonus Tips, as you read it till here…

i) - Use this file to explain your project by writing a description of the same. Provide basic initial setup commands and also mention the languages & third party packages you used while developing certain applications.

ii) .gitignore - As the name suggests, it is a plain text file where each line contains a pattern for files/directories to ignore while pushing your code into the repository. Generally, this is placed in the root folder of the repository, and that’s what I recommend.

iii) git config - It is used to configure your username, email, and password, etc

git config --global "userName" 
git config --global "[email protected]"