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 First Commits Staging Changed Files

Erik Embervine
Erik Embervine
Python Development Techdegree Student 2,442 Points

what is the purpose of the staging area?

if we make a change to a file, what is the purpose of staging it before committing it? won't git record the change once it's committed?

1 Answer

The purpose is to let you pick which files are going to be commited and which not. Sometime's there's going to be files like personal notes, or programs that you use and should not be included on git and you can always double check what is staged and un staged specific files prior to going for the commit. Once you commit you can always go back to a previous commit but it's much easier to check your staged files and make sure you got staged what you want to commit.

If you're sure what you're staging then you can just do 'git add .' and this will get ready all your changed files ready to be commited next.

The other important thing here is that sometimes you'll have a file where you did something you're not sure what is it but it completely broke your code, however the rest of your staged changes are good but on that concrete filr something is just bricking your code. If you do 'git status' git will tell you how to restore just that staged file to the last commit so you wont have to start everything over.

And keep in mind the ultimate goal is to do commits every time you make a little progress so if something falls out of place you can always go back to that starting point. It takes some time to get used to but once you do it's a life saver.