Getting started with git CLI

What is a CLI?

CLI stands for Command Line Interface. You get to use the Command Line Interface in a terminal application. Whatever system you use there are multiple terminal applications available. Here is a brief list depending on the operating system:




When a terminal application boots up, a command line interpreter is invoked. Most popular one are bash, sh, zsh, Power Shell, but there are many other. The terminal application is now waiting for your input, commands.

Gnome Terminal with ZSH prompt.

In this article, I will assume you have a shell interpreter, which is very common on Linux or Mac.

Your first git commands

Let’s verify that git is installed on your computer, just type:

git version

You should get something in return like:

git version 2.38.1

Now it’s time to get started with your first repository, create a new folder with mkdir.

mkdir git-training

Navigate into this folder with the cd command:

cd git-training

Initialize a new repository:

git init

Probably the most used git command, git status will indicate on what branch you are and the status of the files in the repository:

Git status of a new and empty repository

On the screenshot above, you can read we are on the main branch, with no commits and no particular file in the folder to track. Let’s create a new file and try to commit it:

echo "Hello world" >

If you check again with git status, you should see our newly created “” file as “untracked”. It means we are not versioning this file yet. Let’s add this file and create a first commit with it.

git add
git commit -m "Add a basic readme"

Now you have done your first commit! 🎉
To see the commit history on this branch, try this:

git log

Exit the history with “q”.

Git log shows us the history of our commits to the branch.

Try it yourself now, make some modifications in the “” file and commit them 🧑‍💻

Now we see two commits in our history

Push a our git repository to github

Go to, connect to your account or create a new one, and click “new” to create a new repository. You can make it public or private, as you wish, but remember to keep it empty (let empty the “Initialize this repository with” section). If you initialize it with some files, GitHub will automatically create some commits and it will be difficult for us to publish our own commits.

Create an empty repository on GitHub

Then copy the HTTPS URL (or the SSH one if you already configured your SSH keys).

Copy the URL of your repository

And add this URL as the remote for our repo:

git remote add origin

Now you can push your commit history to GitHub

git push

If you used HTTPS, GitHub will ask your credentials.

Let’s go back to GitHub and refresh the repository page.

You see it? Our fresh repository with two commits and a

And there you go you have a repository versioned with git and store online thanks to GitHub 🚀

Related Posts

git logo

Git cheat sheet

Create or clone a repo Creates a new repository in the current directory Clones a repository from the URL specified. Can be HTTPS or SSH. You can…

Vite logo

An alternative to create-react-app, Vite!

The motivation I’ve been developing with React for years now, and more recently using Typescript. And there is one thing that never changed, and I’m a bit…

Leave a Reply

Your email address will not be published. Required fields are marked *