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 trialJen Hamilton
9,994 PointsError in Code Challenge: Staging Our Changes
I'm not able to get past challenge 5 of 6 for this code challenge. I've tried every combination to commit changes, but nothing works:
Challenge: Now let's commit all the changes we made to the staging area.
git commit -a -m "message"
git commit -a
git commit -m prototype.html "message"
That first command should have worked, I don't know what the problem is. Any suggestions?
12 Answers
Jen Hamilton
9,994 PointsNever mind, it's just way pickier than I thought.
git commit -m "message"
Andrew McCormick
17,730 Pointswow.. just sat there for 5 minutes typing in various -a , -am, -a -m... etc thanks
James Barnett
39,199 PointsThe command line is picky about what you type, each of those things does something different.
Andrew McCormick
17,730 Pointsyeah, but I was just trying anything. When it said let's commit all the changes, I thought the -a flag was appropriate.
I read now that -a adds files and commits them rather than just committing the staged file. So if I'm working on 30 tracked files and needing to commit them all, I guess it would be better for me to just git commit -a, rather than adding each file and then committing?
Bryan Knight
34,215 PointsThis is good because I'm currently going through this challenge and stuck thinking the -a was appropriate.
Caesar Bell
24,829 Pointsbut to save all the changes I thought you had to use the -a tag?
Reed Williams
3,323 PointsSame here. Maybe this is a point in the tutorial for revision.
Feng Ji
Courses Plus Student 896 PointsI was stunk there also. Why so many times nobody change it?
anthonyotyehel
3,823 PointsThe tutorial was a bit unclear on this point...I would agree with others here.
Ken Wilson
7,885 PointsThis is extremely unclear. It should really be git commit-a based on the question but this comes up incorrect.
TJ Tijerina
15,273 PointsDamn... this problem is already 2 years old? Thanks to all here. I was confused that my answer didn't work
Stephen Garner
Courses Plus Student 11,241 Pointsyeah man. seems a little strange that "git commit -a" doesn't work. it should work according to the question.
sergei zh
2,687 PointsHello, support team of treehouse!! I have same issue, but it looks like entire treehouse company out of the office, don't read any posts and unable to help...
Michael Delgado
18,792 PointsHello all,
"The correct answer is actually not to use the -a
flag. The question is asking you to commit all of the changes in the staging area, not all of the changes. By default git will only commit changes that have been staged, or added to the staging area (which is what the git add
command does). The -a
flag is a shortcut that will add all of your current changes to the staging area first before running the commit command.
This is a subtle distinction but it's an important one - sometimes you may have changed 15 files but you only want to commit changes to 5 of them (maybe the others just had debug changes, or are related to a separate change that you're working on at the same time). By adding those changes to the staging area first and then committing only what's in the staging area you can make sure that your work stays separated.
Hopefully that helps. Feel free to let me know if I can help out any further." -Tommy Morgan
The correct answer is in the video "The Staging Area". If, people are still unable to figure out the correct answer I will post it in a response.
douaa atouailaa
6,120 PointsThank you ...this question is the key to understanding the staging area
Omar Farag
4,573 PointsWow. I've been stuck for a day doing this. Thanks.
Alex Stepakov
3,515 Pointsdamn it .... really....