8

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?

2
  • How is it smaller? Commented Apr 9, 2019 at 15:31
  • Updated question Commented Apr 9, 2019 at 15:34

2 Answers 2

11

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.
Sign up to request clarification or add additional context in comments.

Comments

3

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"

6 Comments

Right, but how do I do it from the command line? Like with a commit -m But that does not work with a pull
I updated to be able to merge and setting the message without having the editor being spawned.
So what exactly, is "remote-name" -- does this mean that my smaller branches need to be committed to the remote repository? (right now it's only local)
remote-name is your /path-to-large-repo/. I just read the doc and saw that git pull accepts paths and urls as first argument
So the git fetch is working, but the merge is not. I am getting "merge: /path-to-large-repo/branch-name - not something we can merge
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.