In the part 1, we talked about Git, its features and how to install it. In this article, we will see some basic commands to get you started with Git. If you are an absolute beginner this tutorial will help you to get started. In case you are an experienced user of Git, you can skip this article or just see some commands in case you have forgotten any of them.
Before you start this tutorial, you should create a GitHub account and create there a repository.
Let’s begin with the tutorial. The first thing you should do after you install Git is to set your username and email address.
My username is “linuxey”, so I entered in my terminal the following command.
If you use a web-based Git repository like GitHub be very careful that this email is the same one with the email you have provided to GitHub.
My email is “firstname.lastname@example.org”. That’s why I wrote the command below in my terminal.
Cool, now you can see your username and email with the following command.
I got the following results because I entered as a username “linuxey” and my email was “email@example.com”
If you made a mistake you can correct them by running again the first two commands.
Well, till now you learned how to enter your username and email correctly in Git. Now, we will learn how to clone a GitHub repository in our Linux machine. Run the following command by doing some changes according to your situation (by changing the GitHub link and your folder where the clone will be pasted).
You should go on GitHub where your repository is located, copy the link and replace my code above. I cloned my repo to a new folder in Desktop. You could move it anywhere you want, but be sure that the name of the folder you set isn’t created before. This command creates a new folder and moves the repository files there, but it can’t overwrite an existing folder and sends an error.
In this part, we learned how to setup our username and email in Git. Also, we learned how to clone repositories on our Linux machine. In the following days, I will continue this tutorial. If you have any questions write me in the comment section.
This article is part of the series Starting with Git on Linux.