Hello, guys, this is Harshith and in this article, I am going to walk you through the basics of git. So let’s get started
First I am going to select a folder (test)
Ok now I am going to break down the steps into 4 different segments: Initialisation, Staging, Committing, and finally Pushing
Now I am going to start by installing git using this command
sudo apt update # Updating Packages
sudo apt upgrade # Upgrading Packages
sudo apt install git
I am going to use the command “git init” which is going to create a new hidden folder called .git
ls -la
Then I am going to create a new file called a.txt.
Now we can see an ‘x’.
This indicates that some file is being Untracked. To check which file is, We are going to use
git status
We can stage it using this command which will add all the files
git add . # '.' ➝ all the files and folders of the directory
Now when we run “git status” we can see that we need to commit a.txt.
Now we need to commit the changes using this command.
Now for the last step, we need to push it to a repository or repo. I am going to use one of the popular git-service called GitHub
First, create a repository. Make sure it’s private because no one wants to see an empty a.txt file
Then add an ssh key which you can by going to Profile>SSH and GPG Keys
Ok now copy the ssh URL and then go to your terminal and use this command which is going to connect our repo to GitHub
git remote add origin {https} # don't add the curly braces!
Now you can push the repo by running
git push -u origin master
This is going to push all the files to our private repo. Then reload the page and you will find a.txt
Notes for Windows Users
You can’t directly download git using the command line so you will have to download it from https://git-scm.com