Hello Everyone!

Today I am here to tell you more about GIT. As we learned about three tree architecture in previous lecture, today we shall learn “GIT add file”. How to add file in command line. We will also learn how to edit, delete and move file. These are very simple commands to do this, hope you will feel help full.

If We check the status of our present condition before adding the files, the below display will appear.

add file


GIT Add File

Let us start by adding file command. Make two files and add files in the parent directory or the project. As shown in the picture below:

Add file

As you can see I added three files in the project. But I didn’t add files through GIT command.

Now let us go to the command bar and give command to GIT about adding files. As we all know we add files by giving the command “git add .”. This command adds multiple files at a time or you can say multiple or every changes at a time.

But if you wanted to save the changes of a single file git also help you with that by “git add example”. This command helps you to add a single file at a time. Just you need to write the name of your file in the place of example. Before this we need to check our present status. Let take a look on the below picture.

add file

As you can see in the above picture I checked the status of my git files and it shows me the untracked files. It is showing those two files which I added in the folder of my machine. Why they are untracked? Because they are in the working directory and needs to be added.

Now we need to give add file command to git. Take a closer look on the below picture:

add file

In the above picture you can see I gave the command to add the second file. Then I checked the status and git shows that the file has been added. Now the file is in staging index tree and needs to be committed. It is still showing an untracked file, because I didn’t added the third file.

Now I need to commit the second file to move that file in the Repository tree. Take a closer look below.

add file

So what do we have here? Look closer I gave a command to git, to make commit of the file I added. So it tell that one file is changed.

I shall do the same for the third file. First I add file then checked the status, it tells the file needs to be committed because it is in staging tree. Take a closer look below:

add file

As you can see I wrote a command “git add third_file.txt”, what it did? It added the represented file. Then I gave the command “git status”, it showed me the file is in staging tree and needs to be committed.

Now I wanted to commit the other file same way I did earlier. Take a fast look on the below picture:

add file

I gave a command “git commit -m” followed by the message in quotations. It showed one file changed. Now check the status weather everything is pushed into the repository tree or not. You can see the status in the below image:

add file

As you can see it tell that nothing to commit, working tree is clean now.

Now I wanted to make change in the existing file. I make changes in the second file and checked the status. GIT tells that the file is modified and needs to be committed.

add file

In the above picture the red color line shows the change or you can say it is defining the changed file. If you look closer git also tells you the commands to add or discard the file.

Add file which is modified

Take a closer look on the below picture. There are two commands are implemented.

add file

What do we have here? I added the file by add command and then checked the status. Remember adding new file or changed file the command is always same. As you can see one file is still in the working tree and one in the staging tree. Now I shall commit it. Take a closer look on the below file.

add file

As you can see I committed the file and pushed it into the repository. I shall do the same with the other file just take a fast look below.

add file

In the above picture you can see I add file first then checked the status and in the end committed it.


While working in the project as you have made changes in more then one file. So you wanted to know what changes you have done till that. Git helps you with this, there is a command to check the difference between previous and changed file. “git diff –staged” is the command that helps us to deal with this. Take a closer look on the below picture:

add file

There was a file named “1.txt” in my project. I edited that file and gave git the command. As you can see the red colored statement is the previous text present in the file while the green colored text shows the new data stored in the file.

Now check the status, you can see it shows one file has been modified. Take a closer look on the below picture there is an other thing I wanted to tell you.

add file

I deleted two files from my project. both of them are the pictures. Git tells that these files are deleted but on committed or deleted through git command. Now see how git delete the files. Take a close look on below picture:

add file

You only need to give a command. “git rm example”, this command will help you to delete the file. Just give the name of your own file.


Write the command properly otherwise it will not work. Do mention the parent directory otherwise it will fail to work. Always follow the sequences. Follow the pattern.


So what we learned today? We learned how to add changes to the files, how to track the changes and how to delete the file.