Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding files to git index without committing

When using Git, my workflow usually involves firing up TortoiseGit and selecting the files that i'd like to commit.

This (i assume) runs git add (?) and commits these changes to the local repo.

My question is -- why is the separation between ADDING files to the index and COMMITTING them needed?

Are there any use cases for simply adding files to the index without committing them at the same moment?

like image 314
lysergic-acid Avatar asked Aug 01 '26 14:08

lysergic-acid


1 Answers

Adding files to the index is called staging. Staging provides a separation between what is to be committed and what is to remain outside the commit. If you made some changes that are better suited for a different commit, you can just leave them there without staging and make a commit for things that were added to the index.

So, in essence, it helps you prepare simple, coherent commits.

like image 94
r.v Avatar answered Aug 03 '26 06:08

r.v