Presented by Krishna Prasad

About Us

What is our aim

Git add ( git add ) Command

git-add - Add file contents to be indexed for commit

This command updates the index using the current content found in the working tree, to prepare the content staged for the next commit.

  • To add a particular file, use the following command: $ git add path/to/file
  • To add a all changed files, use the following command: $ git add .
  • To add a all changed files of a directory, use the following command: $ git add path/to/directoryOnly

Before adding into index i.e before running above command, if you do $ git status all changes files listed with red colour [default colour if you havn't changed it] once you add it into index by using above commands and then check $ git status all added files are ready for commit and visibles in green

What if you have incidentally indexed a file using bove command and you don't want to commit in the next commit, How should you remove the index file from next commit?

Simple you have to un-index it from stage file by the following command $ git reset git-add/index.html i.e $ git reset fileName will remove the fileName from staged/indexed from next commit.

After each add commands you can check the staged files by the command $ git status, for details of git status command, please click here