How can we use git commands?

Hello techies, welcome to the admiring concept of programming. Whether you are making commands and trying to learn commands for daily GitHub program but still you are in dilemma to take about git command that how can you control over them and become an expert in using the command. So, here is the place where you can get all stuff related to your command line that matters most in your GitHub.

Experimenting with different commands together

If you are using different commands then this process will make you prodigy with extra activity. Now, if you take command as $ git add –A then your file will come in the staging area. When you will select a command like $ git status so, it will show you, your new file comes there. Continuously, you will have to run the command git status and clear so that your command sees properly. If you have sent your file in the staging area then you have to check in the staging area so, you will look at command $ git status then your file will be in the staging area. Suppose, you have to remove from the staging area then one of the commands will happen such as $ git rm –cached, you will type this command with file name so, it will remove from the staging area. Again, you will run a command like $ git status then it will move to the unstaged and become an untracked file. Now, you will do one thing that Suppose, you want to add that file again which had been unstaged. So, your command will be $ git add A, and you want to do commit that. Then you will put $ git commit –m “This is a waste file so, this message will move in git commit. You can see through git log or if you want to see one file then you will type $ git log –p -1.

Removing staged files command

You will see there all add files. Suppose, you have to remove so, what will you do first? You will put like $ git rm –cached xyz.html then the file will vanish, which means they will remove from the staging area. Again, you will do commit, for commit what will be the command, you will put $ git commit -m “deleted the waste file xyz.html”. These are the git commit messages whose you are knowing that what is happened to which commits so, you have been deleted that. if you want to delete the file xyz.html from the hard disk where you have kept in the file explorer then you can put like $ git rm xyz.html then from where the file will be force removal. When you will type $ git rm –f xyz.html so, you will see that file will be deleted from the file explorer. If you will put a command like $ git status then it will show that everything will be committed. Suppose, you want to see short summary of status then you will put $ git status –s.

Shortcut of status

If you put $ git status –s then nobody will give you output unless your working tree is clean. Suppose, you have a file in the name of contact.html and done any changes in that to reaching vs code so, as you put like $ git status –s then it will show your file has been modified. So, again, you will add by $ git add –A when you will put $ git status –s then it will show both modified and add the file.

What is gitignore?

Now, we see that what is gitignore happen? First, you will make a file by $ git .gitignore then you will see in fetching vs code, there will be a file present in the name of .gitignore with a unique icon because it is given through GIT. You add such types of files in this which you have to do ignore them. Suppose, you have made files like log, text, images, and folder, if you want those files in the folder, they don’t track or commit them. So, what will you do? First, you will make a file like $ touch mylogs.log then you will see, there will be a file in the name my logs if you have been written anything commands like processing, download, and upload. You want these command which is in the log files not to be uploaded, when you will do –A then all will move to the staging area. What will you do in gitignore? You will only put the name of my logs file in the gitignore, when you will do track it through $ git status then it will show an untracked file. You will add .gitignore by putting $ git add –A, as you will put $ git status then all my logs file will be tracked. You can do as this suppose, you have made a file in the name of my logs.log then, again, you will run git status then it will not know your file is made or not before it was done. When you will make a file in the name of hello.html then anything you will write of Html file so, you will run git status then it will show hello.html file untracked and it is ignored mylogs.log file because you had put that file in the gitignore. There is a folder my logs, you only want under of that file be ignored, rest of the logs don’t be ignored then you will move to GIT ignore file and you will write my logs, by doing replace whatever there was written before. Again, you will run git status then it will show that it is ignoring my logs named folder under that files also, rest, it will show you my logs.Log file is untracked. This is the real meaning of gitignore, you can do so many things in that suppose, you have CPP files, you want to ignore them so, and you have put .cpp in the gitignore file then it will ignore all CPP file extension. Again, you want to ignore all log files then you will put *.log so, it will ignore all log files. When you will run git status then the untracked file will not show so, you will do a normal by $ git add –A. Again, you want to do ignore my logs that are unmodified and don’t happen commit then you will run git status so, you will know about which has been modified. So, directly you will run $ git commit –m “adding git ignore file” then your file will be committed.

Related video:

 

                 

Facebook Notice for EU! You need to login to view and post FB Comments!