Git: Add Files
What is Git Add
After you made change to files, you need to do the following steps, in order:
- Add the file to staging area.
- Commit staging area (files) into (local) repository. 〔see Git: Commit Files〕
- Optionally, git push to a remote repository. 〔see Git: Push to Server〕
Any file you want to commit, you must first git add
, even if the file already exists in the repository.
The git add
command basically means add it to the “index” file. The purpose of “index” is for next commit. This “index” file is also called “staging area”.
How to Add Files
cd xProjectDir
git add xfilename
git add commands:
git add file1 file2 file3
- several files.
git add .
- all files in current dir. (including new and deleted)
git add -u
- all tracked files in current dir. (no new files)