Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Introduction to Git Managing Committed Files Removing Files

I still don't understand why a deleted file is not sent to the stages for commit?

.

2 Answers

Jamie Reardon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

Only modified files go to the staging area, via the git add subcommand. When you make changes to a file, it's "modified". Therefore, when you add them via the git add subcommand, you are adding them to the staging area/cache.

When using the git rm or mv subcommands, they will go straight to the changes to be committed section.

.

Jamie Reardon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

Yes that is correct Amandeep. Like I said, only "modified"/new files go to the staging area, via the git add subcommand. Deleted and moved files are not counted as modified.

  • git add (staging area process and commit process)
  • git rm and git mv (commit process)

You can review this whole process on an earlier video in the first stage of this course, "First Commits". I have almost finished this course and I have been making notes on most of the videos :)

Tiago Ferrão
Tiago Ferrão
10,873 Points

however i tried git add . and the file shows on the

rm git.html ➜ temp_git git:(master) ✗ git status On branch master Changes not staged for commit: (use "git add/rm <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) deleted: git.html no changes added to commit (use "git add" and/or "git commit -a")

➜ temp_git git:(master) ✗ git add . ➜ temp_git git:(master) ✗ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage)

deleted:    git.html

considering the above, what is the difference between git rm or git add ?