3

Whenever I try to revert a commit using git revert, terminal opens up the nano editor. The revert goes through, but I have to esc out of nano. Is there a way to prevent git from doing that?

On a similar note, is there a way to prevent git from forcing me to add a message whenever I commit something?

Thanks!

yazami
  • 33
  • 6
  • You want it to open a different editor instead? – Edward Thomson May 28 '15 at 02:04
  • +1 to @tom-leu's answer. My personal opinion is if you don't want to bother with good commit messages then there really isn't a good reason to use source control. Backups and journaling work just fine and they are commit message free. – Sukima May 28 '15 at 02:57
  • If nano is the problem here, you can either set vim as the editor in your .bashrc, or just uninstall nano (which makes linux pick up vim automatically) – Anshul Goyal May 28 '15 at 03:46
  • 1
    I don't mind writing commit messages. I didn't know how to revert and include a message at the same time so I was getting annoyed at the editor popping off. Thanks! – yazami Jun 01 '15 at 23:13

1 Answers1

2

If you want to change the core editor check out this answer which explains how.

Making commits without a message is considered a bad practice, especially if you are pushing those commits to shared repositories. This article and this article explain why commit messages are important and some best practices for writing them.

If you still want to have empty commits then this post explains how.

Community
  • 1
  • 1
Tom Leu
  • 142
  • 8
  • Thanks @Sukima, I'll add that to the answer – Tom Leu May 28 '15 at 03:10
  • 2
    Thanks for the links for better commit messages. I didn't know how to git revert and add a comment at the same time so I was getting annoyed that nano was popping off whenever I used the revert command. Edit: I ended up using " git revert --no-edit " to avoid having the editor pop off. – yazami Jun 01 '15 at 23:08
  • @yazami `git revert --no-commit` Then you can commit manually after, giving you the chance to look at your files before you commit. – Sentry.co Aug 11 '17 at 14:55