How to Create Versions in Git Bash

The first step after you install Git on your Windows machine is to verify the git version. If it displays correctly, you can say your git is installed successfully. Below is the process to create versions in git bash.

How to check the Git version

Go to cmd in windows machine. Then type git version, which gives the windows version.

How to Open Git Bash

It is a Linux-based terminal of Git. Do a Search for Git Bash in the windows search box. It’ll be visible. It appears Linux shell.

Why do we need Git

The tool was created to help Linux developers control the development flow among many developers around the world. It helps to solve conflicts, track the modifications, or even revert the configurations that were working before and stopped working in a new version.

How to install git on windows

To install Git, you can access the following link:

Git Bash sample shell

Sample git Bash shell
Sample git Bash shell

How to create a repository

1511 MXTI@avell MINGW64 ~
$ mkdir Chapter09

1511 MXTI@avell MINGW64 ~
$ cd Chapter09/

As aforementioned, you have the output of my Git Bash. Create a folder call Chapter09 and get inside that folder. Here, I will create my first repository:

1511 MXTI@avell MINGW64 ~/Chapter09
$ git init
Initialized empty Git repository in C:/Users/1511 MXTI/Chapter09/.git/

The command git init is responsible to initialize any folder of a Git repository. It basically creates a folder, called .git with a pre-defined folder structure that will store the files with the metadata for your code, like what was changed from the current version of the code and your modifications, which files you want to send to the new version, and other things. A repository is a folder where you store and track the modifications of your code.

How to check git status

I created a new file called code.txt in the text editor, just too as an example with some random content.

Within the Git repositories, we can track the modifications of any kind of text file, Python codes, C++ codes, Java, or whatsoever.

The next step is to check what changed since the beginning when I created the repository and created the file, the Visual Studio Code as integration with the PowerShell. Thus, I will use it to run the Git commands.

The first command is git status

PS C:\Users\1511 MXTI\Chapter09> git status
On branch master

No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
code.txt nothing added to commit but untracked files present (use "git add" to track).

In the preceding command, we can see that we are on the branch master and we have one untraced file, called code.txt.

The branches are the versions that you can have of the same project. You can use it in the way that you want, with the name that you want.

However, create a flow that helps you to keep the standard of the organization. Otherwise, each project would have a versioning strategy.


Now, when we start working on a project, we have the code files that are already in production, and we cannot work in the main branch, because of the CI/CD pipelines. We need to generate a new version of our software with the complete code.

Let’s commit the first version of the code, which will be shared among all the developers working on the same project:

PS C:\Users\1511 MXTI\Chapter09> git add --all
PS C:\Users\1511 MXTI\Chapter09> git commit -m "uploading the scaffold of the project"
[master (root-commit) f6284bf] uploading the scaffold of the project
1 file changed, 3 insertions(+)
create mode 100644 code.txt

If we run the git status again, nothing is untraced or pending to commit:

PS C:\Users\1511 MXTI\Chapter09> git status
On branch master
nothing to commit, working tree clean

To check the branches you have, run the following command:

PS C:\Users\1511 MXTI\Chapter09> git branch
* master

How to create a developer version

Now, we need to work on that code without breaking the version in production, which corresponds to the branch master. Then, we will create a new branch, called, which is the branch respective to a new version of our software:

PS C:\Users\1511 MXTI\Chapter09> git checkout -b develop
Switched to a new branch 'develop'

We created a new branch. Now, if we run the command git branch again, we can see that another version of our current code is created, which we can modify without changing anything in the current version:

S C:\Users\1511 MXTI\Chapter09> git branch
* develop

We created a new branch, then if we run the command git branch again, we can see that another version of our current code was created, which we can modify without changing anything in the current version.


Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.