Difference between git add and git commit

Hi,

Could you tell me what are the differences between git add and git commit ?

Regards,
Christy Behrens

Hi @Christy_Behrens

Basically, git add adds files to the next commit. With git commit ,however, you can make a commit which will create revision with the file changes that were added with git add. If you want to understand it better just think of the file edition as about a three-stage process:

  1. editing
  2. staging
  3. commiting

Firstly the file should be changed. Once it’s done, mark it as ‘ready’ to commit with git add command, and finally, run git commit. This action allows for pushing commits to the repo that is currently being edited, eg. I’ve edited 5 files since my last commit (4 of them are in its initial stage) however, I have to commit one of these files urgently, so I can easily stage and commit this one file only.

Hope I helped :slight_smile: