Git will be Git

Khurram Raza
7 min readDec 19, 2021

This article is about understanding git , git-hub and publishing your first git repository on github platform. Lets hear a story. There are few friends who want to develop a web application which will be used later on but they want it to be developed together and in a manner that it will keep the track of each changes, new features being added, who added or updated those changes. So that later on if a bug arise in any line of code or feature failed. They will be aware of the history so that they may observe the current or previous state of their project. They were bored of traditional copy pasting or sharing of code via email or USB. They needed a system which can bring ease to their life. The system which will promote faster development and better code management.

lets git in

What is the Solution ?


Git came as a solution to them. Git is a distributed version control system. Git keeps the history of changes being added, remove or updated in you code base. It is a powerful tool which promotes rapid software development, collaboration and history maintenance.


A distributed version control system ( DVCS ) is a type of version control where the complete codebase — including its full version history — is mirrored on every developer’s computer. It’s abbreviated DVCS.

After reading the definition we came to know that it will help us in solving a problem. Lets dig in more. I assume that you already have installed git and vscode (Visual Studio Code) on you local machine. If not that you can click on items to download and install them as the tool-tip will represent links. Lets dig in more.

First Git Project :

Open a Terminal or Git-bash .
Verify the installed git version by running the following command in terminal.

git --version

Create a new folder using mkdir command and named it as FirstProject.
Use cd ( change directory ) command to move in.

mkdir FirstProject
cd FirstProject

Git status :

Git status commands gives you the current folder’s status. Either new files are added or modified. It also helps us in identifying tracked file .

git status

Oops! it means your current folder is not associated as git repository.

Git init:

Initiate your git repository by running the git init command .
This command will generate the .git folder which contains all the data structure to store the tracking of your project .

git init

As you can see it initializes a git repository by creating “.git” folder in it. Now your folder has become local repository and it is ready to maintain history. Local repository means the code-base is only available on your machine for now.

Type ls command and see folder structure .

ls -a

Now create a file named as index.html using the touch command.

touch index.html

As you can see index.html file hasalready been created. Now retype git status command and observe the status of your current directory.

git status right after creating html file

A few things can be observe now.
* The branch on which we are working( master ). We will change master to main branch later on.
* No commits yet mean nothing is being tracked.
* The index.html file in red color indicates it is untracked now and git does not maintain history unless it gets tracked and commit.

* The index.html file in red color indicates it is untracked now and git does not maintain history unless it gets tracked and commit.

Now open your current directory in vscode using code. Command or manually by running VScode by double clicking on icon.

code .

this command will open your current directory in vscode editor. Here “.” proceeding code is used for current directory. A pop up will open as ask you for the permission. Proceed with “yes” for now. And write some dummy html code in your index.html file

As you have added some code in index.html and press Ctrl+S in order to save the code. Now all you need is to make your changes trackable and track them by running following commands .

Git add:

The git add command adds a change in the working directory to the staging area. It tells Git that you want to include updates to a particular file in the next commit.

git add <file_path_along_name> 


git add .

Git commit :As you can see index.html is in green color . It indicated the file is in a stage mode and it is ready to commit .

Git commit :

The git commit command captures a snapshot of the project’s currently staged changes. Committed snapshots can be thought of as “safe” versions of a project — Git will never change them unless you explicitly ask it to.

A shortcut command that immediately creates a commit with a passed commit message. By default, git commit will open up the locally configured text editor, and prompt for a commit message to be entered. Passing the -m option will forgo the text editor prompt in-favor of an inline message.Type the following command in terminal .

git commit -m "text-message-that-define-purpose"

“Here I have used an analogy, for example you have some data files and you have made some changes in them. And then add them to staging area. Staging is like a box. You can add multiple files in this box. Once you are done adding you commit it. Commit is like putting a label on your box with a text message and putting it in a safe zone. Rocket is the safest place to keep this box.”

Now you are set. You are done with development. Now you want your repository to be available for other to contribute. It means you need a platform where you local repository will be host. Here we need a platform which will store our repository as in open source or private mode. Ever heard of Github?


Git-hub is git-based repository hosting platform .

A platform where your code base will reside and you can either pull or push the code over there .I assume you already have created an account. Just browser to . Sign in and create a repository named as FirstProject. Keep it public for now .

Click on the New button to create it and it will route you to different page .

Add details and press create repository button.It will route you to different page .

Now you are all set . You have created your repo on github .It is available on remote but your local repository is not synced with remote one . All you need is to push your code . Before it we need to change the our branch name as master is not being used much .So we should rename it from master to main .We will use following command .

git branch -m <old_branch_name> <new_branch_name>

Once you are done with renaming. Now you need to add origin repository url .So that you can push your local repository code . You can add origin repo url using remote command .

git remote add origin <git-repo-url>

Once you are done with this step all you need is to push your local code to origin/host .

Git Push :

The git push command is used to upload local repository content to a remote repository.

Use the following command to push your current “main” branch to origin .

git push -u origin main

Add user name and password for you github profile.

Now witness magic on your github repository. How your local code is pushed to git-hub .

Hurray!! You can see your project content . This repository is now available for others to collaborate . This article was about to get you familiar with git and github. In next article we will learn about merge, branching , pull, clone , stash , git trunk based model and much more . Stay tuned !!

Referance Link