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 Git Basics Getting Started With Git The Staging Area

Emmanuele Massimi
Emmanuele Massimi
7,420 Points

Git add FILE && git commit vs git commit -a

Hi,

I'm a bit confused in regards of the difference between:

git add FILE1.md
git add FILE2.md
git commit -m "some comment"

And:

git commit -a -m "some comment"

Are these two commands achieving the exact same result, or is there any difference? In short, is the "-a" flag just a shortcut for adding all files while committing?

Thank you.

1 Answer

Michael Hulet
Michael Hulet
47,913 Points

You'd be right about your last statement. git commit -a commits all the changes that git finds automatically, whereas git adding specific files and then committing allows you to choose exactly which files you want to commit, and which ones you don't

Emmanuele Massimi
Emmanuele Massimi
7,420 Points

Thanks a lot, this clarifies everything for me.