Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Erik EmbervinePython Development Techdegree Student 1,858 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?
Axel LancieriFront End Web Development Techdegree Student 13,104 Points
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.