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 Introduction to Git First Commits File Status

Jesse Kiwovele
Jesse Kiwovele
7,767 Points

Hello friends! how do you git add a file? check my answer below. Thanks.

I'm trying to git add on this code but I'm getting an error that needs me to specify after 'git add' i believe before 'chapter1.txt'

2 Answers

Tom Settle
Tom Settle
5,127 Points

If you want to git add a specific file it should be git add chapter1.txt. Adding all changes staged would be git add .

Jesse Kiwovele
Jesse Kiwovele
7,767 Points

Got it! Thanks. I was adding a period at the end of my "txt"

Just to expand on Tom's answer, I find it more productive to perform a patch add e.g.

git add foo.txt -p
or
git add foo.txt -patch

When you perform a patch add, instead of immediately adding all the changes in my file/s, it goes through each change and asks you what you want to do (e.g stage, don't stage, edit etc.). This helps eliminate any typos/syntax error I may have made, and also gives me a sanity check to ensure what I'm committing is actually related to my branch!

There's a lot of cool info on this over here

Regards,
Berian