Reputation: 609
I am trying to write a script to make my bulk - git collaboration easier, to push / pull / or commit multiple git projects at once.
I work on multiple sites, and I want to pull all of the current changes for all of the sites at once.
Here is what I have.
#!/bin/bash -e
REPOS=(
/Users/me/repo1
/Users/me/repo2
/Users/me/repo3
)
echo push, pull or commit?
read input
if [$input -eq "commit"]
then
for i in “${REPOS[@]}”
do
cd $i
git add . -A
git commit -m "auto commit backup point"
echo "Moving to Next REPO...
"
sleep 2
done
else
for i in “${REPOS[@]}”
do
cd $i
git $input
echo "Moving to Next REPO...
"
sleep 2
done
fi
Now, when the script prompts me for input, push or pull is working fine (sort of), the script runs through all of sites and pulls or pushes accordingly.
However when I respond "commit
" the script goes through each repo, but the commits are not working properly. The Commit message prompt opens in vi which is not preferred, and the commit doesnt place. If I navigate to any of the repos there are still staged changes.
any input would be greatly appreciated.
Upvotes: 3
Views: 1521
Reputation: 28981
if [$input -eq "commit"]
has missing space. Rewrite it as if [ $input -eq "commit" ]
. Otherwise it goes to else
condition and does git $input
, where input=commit.
Oh, yes, -eq
is for integers, should be if [ $input = "commit" ]
.
Upvotes: 1