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 trialkabir k
Courses Plus Student 18,036 Pointsgit commit -m “some comment” vs. git commit -a -m “some comment”
What's the difference between these two commands?
git commit -m “some comment”
and
git commit -a -m “some comment”
I'm trying to be clear on this.
kabir k
Courses Plus Student 18,036 PointsHey Perry,
What two-step process?
2 Answers
Seth Kroger
56,413 PointsThe -a flag will add any files modified since the last commit to the staging area right before the commit. It allows you to combine the "git add" with "git commit" into one command. It won't add new files you've created though. For those you need to use git add to add them to the staging area.
kabir k
Courses Plus Student 18,036 PointsHey Seth,
I thought the -a option stands for "all" and that git commit -m "some comment" is used to commit a version of your code into the repository?
Kareem Jeiroudi
14,984 Pointsgit commit -a
will automatically add all modified files in the repository to the staging area AND commit them too, which means with this command you can skip the adding (git add <fileName>
). However, git commit
commits only files that are explicitly added to the staging area. I hope that was helpful.
Perry Eising
12,663 PointsPerry Eising
12,663 Pointsmy understanding is that -a adds all of the un-added files to the staging area before you commit them. Otherwise it would be a two step process.