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

Dhruv Patel
Dhruv Patel
8,287 Points

Saving commits

I'm unable to save a commit on Git Bash. I can type a message but I don't quite know how to save the commit and exit back to the main screen. Is there a way for me to do so?

4 Answers

Jane Eyer
Jane Eyer
2,586 Points

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

Dhruv Patel
Dhruv Patel
8,287 Points

Thanks for the answer.

Max Pinomaa
Max Pinomaa
2,647 Points

I did that "nano ~/.gitconfig" and so on, but started to get "fatal: bad config line 1 in file /Users/maxpinomaa/.gitconfig" when trying to add and commit.

Press ESC to make sure you are out of the edition mode and then type

:wq

(found on stack overflow)

A commit just sets your files up so that they are ready to go into the repository (Github for example). After you commit, you need to do a pull and a push to get the files to the server (do a pull first to make sure you aren't going to be in conflict with a prior update). So:<br /><br />

git commit -am "my message" (this will commit all files with a message of my message)

git pull (to ensure no conflicts)

git push (puts your files on the server)

Also, before I commit, I like to do a

git status

as this tells me what files are waiting and whether there are files that are untracked that I'd like to be tracked :)

Jvalant Dave
Jvalant Dave
4,483 Points

Thanks for the answer. I'm disappointed the video doesn't address this, kinda leaves a lot of Windows users in the dark.