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 Committing Changes

Max Pinomaa
Max Pinomaa
2,647 Points

Git stopped working. "fatal: bad config line 1 in file /Users/username/.gitconfig"

I'm using Mac. The commit command opened a different editor than the teacher had. I couldn't get out of there so I just exited the Terminal and started a new one. I decided to follow the advice here: https://teamtreehouse.com/community/if-your-editor-looks-different-and-you-want-to-exit "Jane Eyer over 1 year ago If ctrl + x does not work for you then your git is using vim. In that case, Press esc and type ":wq" (w- means for write, q - means for quit) and press enter.

In the future if you want to use nano as a default text editor. then go to the main screen on terminal. type: nano ~/.gitconfig

The above command line will open an empty file and in the empty file type: git config core.editor "nano"

then press ctrl + x and enter to save and get out.

Happy gitting :D" Things didn't get very happy. My git stoped working after that operation: "nano ~/.gitconfig" and so on. Anything I try to do with Git in the terminal now, I get fatal: "bad config line 1 in file /Users/maxpinomaa/.gitconfig".

So I guess I changed the git settings. How can I fix this?

4 Answers

This command will open the .gitconfig file:

nano /Users/maxpinomaa/.gitconfig

And it should look something like:

# This is Git's per-user configuration file.
[user]
        name = NAME
        email = EMAIL
[core]
        editor = nano

If you used emacs or vim instead, you would replace 'nano' with your preferred editor.
What are you seeing that's different if you run that command?

Max Pinomaa
Max Pinomaa
2,647 Points

Thanks for your answer. I opened the file with "nano /Users/maxpinomaa/.gitconfig", and the file contains only one line, and that is: git config core.editor "nano".

git config core.editor "nano" looks like the original command to add nano as your default editor.

At the very least you'll need to remove that line, and you can replace it with:

[core]
        editor = nano

However you may also want to add the [user] section as well, or git may ask you to set up your name and email when you go to make your next commit.

Max Pinomaa
Max Pinomaa
2,647 Points

Thanks a lot! By the way, sorry, at first I read your first answer a bit wrong. I have to get into the habit of reading texts more carefully. I understood your message "And it should look something like:" as if you were saying that "this is most probably what it will contain:". :)