请看一下我为此目的创建的示例bash脚本。 链接到Github回购
#!/bin/bash
# Script Name: git-bash.sh
#
# Author: Krishnadas P.C
# Date : 05-05-2018
#
# Description: A simple script to manipulate git files.
# TODO add more options and add Error Handlers.
#declare color variables
red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`
#print the current git branch
echo "On Branch - $(git branch)"
#Get only staged files
gitstaged=($(git diff --name-only --cached))
#Get changes not staged for commit
gitnotstaged=($(git diff --name-only))
#Get only untracked files
gituntracked=($(git ls-files --others --exclude-standard))
if [ $# -ge 3 ];
then
if [ $2 == "st" ];
then
git $1 ${gitstaged[$3]}