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:
Linux:
MacOS:
Windows:
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.

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:

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" > README.md
If you check again with git status
, you should see our newly created “README.md” 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 README.md
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”.

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

Push a our git repository to github
Go to github.com, 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.

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

And add this URL as the remote for our repo:
git remote add origin https://github.com/cchampou/git-training.git
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.

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