Home > Net >  How to save commit changes without editing when doing a merge in a script?
How to save commit changes without editing when doing a merge in a script?

Time:02-12

I wonder how to add in my basic script some commands with nano, Ctrl-O, Enter, Ctrl-X, Enter. You can see what I want at the end of the script. It is after git merge, I just need to save commit changes (formality)

#!/bin/bash

## Set Local Rebase ##
git config pull.rebase true

## Update OpenWRT Scripts
./scripts/feeds update -a
./scripts/feeds install -a

## 5.4 kernel
git remote add wrt https://github.com/james/openwrt.git
git fetch james
git checkout -b wrt james/kernel5.4-qsdk10.0
git checkout master
git merge wrt
*ctrl o*
*enter*
*ctrl x*
*enter*

CodePudding user response:

Instead of having to interact with your editor to set the merge commit message, you can use the -m flag to specify a commit message without opening an editor, or the --no-edit to accept the default message. You can also use git fmt-merge-msg to help generate a message to pass to -m, but that's a bit harder.

Using --no-edit:

git merge --no-edit

Using -m:

git merge -m "automated merge by my script"
  • Related