Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Development Tools

Jamie Bradley
Jamie Bradley
7,148 Points

Merging>Basic Merging: What's wrong with git commit -am"message?!?!"

I'm working in the Basic Merging challenge and I keep getting an error message for using the wrong flag. I tried -a -m to add a branch and write a message, I tried them separately, then I looked it up on SO and used -am. Nothing worked! What did I do wrong? :'(

3 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Jamie;

Not entirely sure what you are attempting to accomplish. But, let's look at a couple things.

The -a (--all) command is an option command for, example when you use git commit to tell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected.

The -m (--message) command uses the given <msg> as the commit message. If multiple -m options are given, their values are concatenated as separate paragraphs.

The git branch command will allow you to work with whatever branches you may have.

If you continue to get stuck, the command line git help is very thorough and informative. If you do a git help add or git help commit it will take you to an html doc that has lots of information about that specific help topic.

Best of luck and if you have any additional questions, please do not hesitate to ask!

Eric Vandenberg
Eric Vandenberg
9,095 Points

Hey I just tried out this challenge and I think you are mixing up committing changes in a branch with merging a branch back to the master...

To add a branch use $ git checkout -b name_of_branch

This will switch you into this branch as you create it all at once from this one line

If you already have your branch created you don't need to use this line above. But make sure you select that branch using:

$ git checkout name_of_branch

Next you can make changes in your files using $ nano filename

To commit these changes under your new name_of_branch use $ git commit -m "description of changes"

If you made multiple changes in multiple files use $ git commit -a -m "description of changes"

Then to merge the branches you must revert back to the branch master $ git checkout master

Finally, to merge the branches, simply use $ git merge name_of_branch

git commit -am "message"

is the correct syntax for committing to git. In you're question, you haven't left a space between the -am and double quotes, maybe it's that? Are you referring to a treehouse test or your own local work?