mmaceachran
mmaceachran

Reputation: 3338

Git automatic merge commit message

I have split one giant repo into several small ones. The old repo is still being comited to so I have to keep updating my new smaller ones.

I did this by doing this:

git subtree split -P some-sub-directory-in-my-large-repo/ -b branch-name-I-split

Obviously, I am trying to script this out, but I can't get past this:

cd my-smaller-repo
git pull /path-to-large-repo/ branch-name-I-split

And that of course brings me to the editor.

I need to just accept the default message and move on...

Any ideas?

Upvotes: 5

Views: 9685

Answers (2)

James Gawron
James Gawron

Reputation: 969

You can use the --no-edit flag to accomplish this.

From the git docs

--edit
-e
--no-edit
Invoke an editor before committing successful mechanical merge to further 
edit the auto-generated merge message, so that the user can explain and 
justify the merge. The --no-edit option can be used to accept the auto- 
generated message (this is generally discouraged). The --edit (or -e) 
option is still useful if you are giving a draft message with the -m 
option from the command line and want to edit it in the editor.

Older scripts may depend on the historical behaviour of not allowing the 
user to edit the merge log message. They will see an editor opened when 
they run git merge. To make it easier to adjust such scripts to the 
updated behaviour, the environment variable GIT_MERGE_AUTOEDIT can be set 
to no at the beginning of them.

Upvotes: 8

padawin
padawin

Reputation: 4476

Your smaller repo probably has a different log of commits than the large one. So when you try to pull, it will merge the large one in the small one. Because it makes a merge, your editor is open. To quit it, it depends on the editor:

  • if it is nano, you can quit it with ctrl-x
  • if it is vim, you can quit it with :q
  • if it is emacs, you can quit it with ctrl-x ctrl-c
  • otherwise, it'll depend on the editor, a screenshot would help us knowing which one it is.

If you don't want the editor to be spawned, you can use git merge instead of git pull:

git fetch remote-name
git merge remote-name/branch-name -m "Merge message"

Upvotes: 3

Related Questions