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

Kieran Barker
Kieran Barker
15,028 Points

Is there a difference between git rm tins.html and rm tins.html -> git add tins.html?

If I execute git rm tins.html, the tins.html file will be removed from the current directory and this change will be moved into the staging area.

Is this the same as executing rm tins.html to remove the file, and then git add tins.html to add this deletion to the staging area?

1 Answer

Assuming you already have a tins.html in your working directory and the git repository (i.e. it has been staged and committed earlier),

git rm tins.html

removes it from the working directory and stages the deletion. You will need to commit to remove it from the repository too.

With rm tins.html, you have an additional step to git add tins.html, to stage this change.

So, yes. They have the same effect. One is cleaner than the other.