How can we build git commands?
Hello techies, welcome to the configurable world of programming. Today, we are going to talk about facts that matter obviously in your git command order. Whether you have fear regarding the command line. After reading, these awesome steps, you will be gain more awaking and stability on the command line. Perhaps, before learning new stuff or things, you have doubt on either you will be eligible or not in getting that. So, this comprehensive part will make you precisely expert in the daily upcoming command matters.
Four stages of files
Some have terms related to git. Let’s have a look at the terms. There are four stages such as untracked, unmodified, modified, and staged. Let’s look at these four. Whenever we make a repository, initialize the git. There is an untracked file, what does it mean? Just until git is not giving care to them. They will not track them, nothing will do, whatever you will do, it will show untracked to you. If you will do adding the file then it reaches the staging area, what is the staging area? the Staging area is the place where your file is ready to be committed. What is a commit? It means, one type of you have been done all codes, you are ready to upload them. Suppose, you make a program doing little-little now, the program doesn’t make at once. So, Doing little, you are ready to upload, one work, one module has been made, you will upload this, the second module has been made, you will upload that. So that, your file is not going to vanish or lose. This has been happened about staged and untracked. What is unmodified happen? Whenever you do commit, suppose, you have done commit then it will move into the unmodified. After doing the commit, firstly, you will do untracked to add file then it will come in the staged area. Again, what will you do? You will do commit so, it comes in unmodified. Suppose, you have a program, there is a file which is in commit then after, you have added some more commands in that. What will happen next? The file will be modified. Again, you edit that file then it will show you modified because you have modified and added codes to them. Again, you have to do stage the file and commit, you can also remove that file from commit. These all are special stages of commands, you may also see that through the command line. Everything will come in understanding if you will see through the command line. Now, you will move to your git bash and make some files over there. You would make a file from touch, touch is a command which is used for making empty files. Suppose, you want to make a blog site then you need some files like $ touch about.html again, you type $ touch news.html, you have made two files then you will see vs code, the two files will be there to the name of about.html, and news.html. These two files will be empty, you have made these files through the command line. Now, you will check by writing some Html codes so, you can make your own basic structure like Html: 5 then your full page layout will be ready like this,
<! DOCTYPE html>
<Meta name=”viewport” content=” width=device-width, initial- scale=1.0”>
<Title> about page</title>
This is about page
<! DOCTYPE html>
<Meta name=”viewport” content=” width=device-width, initial- scale=1.0”>
<Title> News page</title>
This is news page
Suppose, you have been made these two things so, again, you put $ git status then there will show untracked files. If you want to track all files then there has a command like $ git add about.html then it will do track. Now, you will put $ git status so, it will show you two files one will be tracked or another will be untracked. Suppose, you have ten to twelve files, very huge projects, and so many files so, you will not do it one by one. For doing at once, what will be the command? Then the command will be $ git add –A so, your all folder files will be shifted into the staging area. When you will type $ git status then all your files will be shown in the staging area. You can do unstage so, you will see just how we can do unstage.
Git commit command
So, lets us do commit this, what would be the command for doing commit? For commit, you will put like $ git commit –m “the first commit” when you do enter from there will be committed with the message. So, there all files will be commit
[master (root-commit) 3b17be6] The first commit
— Files changed, —- insertions (+)
Create mode 100644 .vscode/settings. json
Create mode 100644 about.html
Create mode 100644 news.html
Get checkout command
Suppose, something has happened as your file has been deleted. At once, you have been done commit after that, your all files are deleted by anyhow or somebody has saved that and closed it. Also, the editor has been closed. So, for retrieving that file, one command is happen there. Through that file, it matches your previous commit so, what are they happen? $ git checkout about.html, you will see that your about.html file will retrieve once again. It means your all files have been deleted after doing save. You have ten to twelve files that have been deleted but one time commit should happen, you have done commit and all your files have been deleted. So, you have to retrieve all files then you will type like $ code. Then your vs code will open. You have saved your file and deleted them, if you have to match these files to the previous commit, those have been deleted and you want to retrieve that files into about.html and news.html. So, the checkout one more command happens like $ git checkout –f, when you will put this then it has been matched all files from the previous commit. You will see that all files are available in vs code, it is a useful command. From here, the benefits will be ready to see you, why do GIT use? For what GIT is used? These all benefits, you will have to see that if your file will have been deleted then how you can retrieve them and match to the previous commit. About these all thing, you are seeing.
Git log command
One more command happens whose name is GIT log. What does it do? When you run the $ git log command then it will show you all details about the first commit like the author, and date. Suppose, you have done a hundred commits so, you will do GIT log then all commits will be retrieved there. If you have to see two or three commits then what will you do there, you will put like $ git log -p -1 so, it shows your last commit in detail with diff. what is diff.? You will see just now, there will show you first commit and what changes you have added in that. When you will press Q then it will happen quit and will move in the editor. Suppose, you make a file like $ git touch contact.html then the file has been done. You will see that your file will be ready in vs code to the name contact.html so, you will write code, as usual, you have written previously in that. You will see a U signal besides contact.html which means it is unstaged and untracked. You would continuously run the $ git status command so that you should know what is happening in your file then it will show you the contact.html file and untracked also. First, you will add that by typing command $ git add –A so, it will come in the staging area. When you will put $ git status then your new file will show there. So, you do any advancement in the news.html file and you have added them in that file then what will show to you? When you put $ git status then it will show you modified because you have done changes in that.
Again, you have to send in the staging area so, as you will write $ git add –A then it will move to the staging area. So, GIT will hold your all records like what are you doing or not? You will add some features in all files so, again, you will run the command like $ git status then all your files will show you modified. After that, you will do add in staging area and commit that by $ git add –A. Again, you will run $ git status then it will show your all files status, if you will write $ git commit –m “Adding the new features to files” then it will show your file details. Suppose, you have added some features in all files through going vs code, let them will save otherwise, the effect will not happen then again, you will put $ git status so, all will be modified, you want to do a direct commit, without sending them staging area. So, there will be commands like $ git commit –a –m “skipping the staged area” from there, staging area will have to give skip and directly, they will be print so, you can check through $ git log p 2 then everything will show you there. If you will put Q then it will do quit from the editor. When you will do $ ls then it will show you all files, like $ pwd, $ ls command, these all happen unique command, you are using in git then it is also work as a terminal command in git bash. Suppose, you make a file by default to the name $ touch delete.html, you have added some feature in that file then you will type $ git status then it will show you untracked because you have not added in the staging area.