Question

I would like to do the following in a script:

git merge --squash someBranch
git push

The problem is that the merge does not do a commit. So before the push I have to commit. The default commit message created by this merge is sufficient. So my questions are:

  1. Can I do the merge with automatically generating the commit?

  2. Or can I add a command in the script to do a commit which accepts the default message?

Thanks!

Was it helpful?

Solution

The default commit message after a merge is in .git/MERGE_MSG, so you could do the following:

 git commit -F .git/MERGE_MSG

... after the merge.

OTHER TIPS

It looks like in more modern versions of git, you can try using the --no-edit option as described in the git-merge docs and in this SO question.

git merge --no-edit --squash someBranch
git push

Another way:

git merge --squash someBranch
git commit -m ""

The --no-edit option doesn't work for me (Git 2.7.0). It says: Squash commit -- not updating HEAD.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top