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 trialAhmed Abdelaal
6,328 Pointscommitting
Throughout the video, I've seen that Tommy just committed after editing file2 twice and once after editing file1. He just went ahead with committing though without adding the files to the staging area. This just threw me off a bit so any explanation would be much appreciated!
3 Answers
Stone Preston
42,016 Pointsdid he add all the files to the staging area at the beginning maybe using
git add -A
then commit?
Ahmed Abdelaal
6,328 PointsHe edited the same file twice. The first time he used nano to edit the files and the next line of code was straight into a commit.
$ nano file2
$ git commit -a -m "Edit file2 some more
the second time he used
$ git nano file2
$ git add file 2
$ git commit
what threw me off is that he edited the same file twice using nano but once without staging and then second time he did.
so if I include -a in my commit then I shouldn't have to stage the files?
Stone Preston
42,016 Pointsyes. that will add it to the staging area then commit it, all in one line.
Ahmed Abdelaal
6,328 PointsThank you so much man!
Stone Preston
42,016 Pointsjust note that the one line method will only work if the file is already being tracked in the repo. If its a new file that has yet to be added you have to do it using git add, then commit.
Stone Preston
42,016 PointsAnd that using -a adds the current version of all the files in the branch, not a specific file