Member-only story
Complete Git Tutorial for Beginners with Examples
Git is a version control system that lets us track the changes we make to our files over time. With Git we can revert to various states of our files. We can make a copy of our files and make changes to that copy and then merge these changes to the original copy.
We can install git using this official website.
Configuring git:
To verify git installation, we can open git bash and type the git — version command. This shows the latest version of git installed on our PC.
git --version
The first thing we have to do is to set our username and email address. Git uses this information to identify who made changes to specific files. To set our username and email id, we can use the below commands -
git config --global user.name “Our_username”
git config --global user.email “Our_email”
This will configure our Git environment. To check whether the configuration is succeeded, we can still check our configuration in the local machine using this command —
git config -l
We can also store credentials in the cache, Just to avoid giving them each time using the below command -
git config --global credential.helper cache
Cloning existing git repo to local -
We can clone the existing git repo into the local machine using the command -
git clone https://ourrepo
Creating and Initializing a new project in Git
Create a new folder or navigate to the folder where you want to create your first project. I have used git bash to create a folder test_calculator using the below commands —
mkdir test_calculator
cd test_calculator
Alternatively, you can Open the folder you like through File Explorer, Right click on it and select Git Bash Here
Now once the folder is ready, we need to initialize the project, For this, we need to run the git init command. This will tell git to start watching our files, for…