Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a git commit message using vi on OS X

Tags:

I'm learning using Git on an OS X Terminal. It seems really easy. But I can't handle just one problem: When I try to merge two branches, for example "myTestBranch" into "master" this program covers the terminal and shows me a new view where I should write the merge message. And then, I don't know how to do "Enter", save the merge message and then come back to the main terminal view where I can continue working.

Does anyone know, how does it work?

What I see, when i try to merge

like image 246
GitForJava Avatar asked Nov 03 '15 17:11

GitForJava


People also ask

How do I commit to git on Mac?

Committing via the Command Palette Open the Command Palette. Run the Git: Commit command (type commit and press Enter ) (Optional) Choose the files you would like to commit. Click on Commit or hit Ctrl + Enter (or Cmd + Enter on your Mac)

How do you git commit with message?

To add a Git commit message to your commit, you will use the git commit command followed by the -m flag and then your message in quotes. Adding a Git commit message should look something like this: git commit -m “Add an anchor for the trial end sectionnn.”

How do I add a commit to a message template?

Set a template: Open Settings > Tools > Commit Message Template and enter the desired template or set the path to a template file.


1 Answers

If you haven't change the default git's editor, that "new view" is the Vi program.

To save your commit message using Vi, follow the next steps:

  1. Type i
  2. Write your message
  3. Type the ESC key
  4. Type :wq
  5. DONE! :D

Typing :q, step 4, is not enough beacuse just means QUIT without saving. That's why you need :wq, which means WRITE and QUIT.

You can write your commit message using your favourite editor(vim, emacs, etc.). To achieve this, you can use configuration parameter or environment variables, listed in order:

  1. GIT_EDITOR environment variable
  2. core.editor configuration option
  3. VISUAL environment variable
  4. EDITOR environment variable

Using the configuration option type something like this:

$git config --global core.editor "nano" 

Or if you want to use enviroment variables, add something like this to your .bash_profile

$export GIT_EDITOR="PATH/TO/YOUR/EDITOR" 
like image 124
Raúl Omaña Avatar answered Oct 02 '22 13:10

Raúl Omaña