Jibby
Jibby

Reputation: 1010

How to make --no-edit work in git?

Sometimes I have to commit the same change across 2 dozen git repositories. I use a script, with the following command so I don't have to type :q two dozen times for the commit message I don't want to change:

git commit -a --amend --no-edit

Problem is, it never works. It still opens the editor and shows me the commit message that I don't want to change.

Can you see anything wrong with the command I've typed, or have any ideas why this wouldn't work? I am using git version 1.7.1, on centos version 2.6.32-573.18.1.el6.x86_64.

Upvotes: 1

Views: 1636

Answers (3)

Mort
Mort

Reputation: 3549

git commit -a --amend -C HEAD: take the existing comment from HEAD.

Upvotes: 1

Mort
Mort

Reputation: 3549

This makes no sense. git commit --amend is for modifying an existing commit. You are talking about making a new commit.

Do you really mean across many repositories, or do you perhaps mean across many branches?

  • Within the same repository, you could use git cherry-pick <commit> to re-apply the same change to multiple branches. That will not require a commit message, it will pick up the message from the original one.
  • In a different repository, you need to make a change to the files. Probably use git apply < <patch_file> && git commit -a -m <commit message>. Your script can supply the patch and commit message.

Upvotes: 1

CodeWizard
CodeWizard

Reputation: 142174

You have to add content before you commit.

If you don't add anything nothing will be commited, You can use the -a flag passed to the commit to also add your content.

If you want you can also type zz to exit vim instead of the :q.

P.S.

Its about time to upgrade your git. Very old version with security issues.

Upvotes: 1

Related Questions