Git command output string to another command input SHELL

Viewed 56

I want bash or shell script for this requirement

Git branch --show-current - $INPUT take it as input

git checkout master

git cherrypick $(INPUT) -- I want to use this input here

So how to do it in shell or bash script

1 Answers

Do you wish to save value of command Git branch --show-current in variable INPUT ? If that is the case, you can try this script:

#!/bin/bash
INPUT=$(Git branch --show-current)
git checkout master
git cherrypick $INPUT

It saves the value of Git branch --show-current in INPUT so it can be used later on in the script.

Related