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

Oliver Sewell
Oliver Sewell
16,425 Points

Hi i need some help with git bash git commit

when i type $ git commit i get this message

*** Please tell me who you are.

Run

git config --global user.email "you@example.com" git config --global user.name "Your Name"

to set your account's default identity. Omit --global to set the identity only in this repository.

ive tried to use the Omit but it says the command doesnt exist? what should i type here?

6 Answers

Austin Whipple
Austin Whipple
29,725 Points

There is no "Omit" command for bash/git. Rather, it's suggesting that you leave off the --global flag from the git command to set your identity. Therefore, to set your identity for only this one repo rather than all of git on that system, use the following commands:

git config user.email "you@example.com"

git config user.name "Your Name"
Oliver Sewell
Oliver Sewell
16,425 Points

Thanks Austin that worked

Marco Boretto
Marco Boretto
29,821 Points

If anybody's having troubles with Vim editor here's some instructions to set nano as the default editor for git. Just type in the console:

git config --global core.editor "nano"

cheers

Oliver Sewell
Oliver Sewell
16,425 Points

Added a README file

Please enter the commit message for your changes. Lines starting

with '#' will be ignored, and an empty message aborts the commit.

On branch master

Initial commit

Changes to be committed:

new file: README.md

new file: README.txt

Changes not staged for commit:

deleted: README.txt

~ ~ What do i enter now ? it isnt really explained in the video what i should enter etc?

Austin Whipple
Austin Whipple
29,725 Points

With every commit to a repo, you must submit a brief message to describe the changes you're committing. This is handy for you when reviewing what you've done if you need to go back, and it is essential when working on a repo with others.

There are two ways to enter a commit message.

  1. The first is what you see here, you perform the normal commit and then a text editor is opened. Here you enter in at least one line of text and save it. The command to save differs depending on the text editor you're using.
  2. The somewhat faster command to commit and include a commit message just requires a -m flag on the commit command followed by the commit message in quotes:
git commit -m "Fixing header layout issues in style.css"

You can even go one step further to combine steps and commit all changes, even those you may not have added to the commit yet:

git commit -a -m "Commit message here."

For me, the commit with the -m flag worked for me, but I attempt to use 'git commit' without the flag, and the same text as seen above appears ... (Please enter the commit message for your changes. Lines starting with '#' will be ignored, and an empty message aborts the commit. On branch master Initial commit Changes to be committed: new file: README.txt etc...)
... and then I type something like "Added a README file." and I can't seem to exit whatever mode I seem to have entered with "git commit". I end up having to close the file in the middle of this process. Any insight? I'm using Gitbash on windows 10 with notepad as text editor.

Austin Whipple
Austin Whipple
29,725 Points

Check out this StackOverflow thread for more information.

Essentially, if you leave of the -m flag, git will open your default text editor for you to enter a message.

Thanks for the reply. What I'm saying is that if I leave off the -m, I'm taken to the screen I describe above, and nothing opens and there seems to be no way off of that screen and no way to complete the process of leaving a comment. I've now encountered the same problem with Merge as I attempt merging for the first time along with the TH tutorial... my exact text was: git merge bar_feature and then I get stuck on the screen that says :

Please enter a commit message to explain why this merge is necessary,

especially if it merges an updated upstream into a topic branch.

Lines starting with '#' will be ignored, and an empty message aborts

the commit.

~

Okay, your link helped me sort it out. Thanks, and sorry for not knowing what I'm doing!! It turns out it is a VIM control thing, and Ctrl C brought up the instructions for exiting VIM, which was to type :quit! .