#! /bin/bash
git_user_name=`git config user.name`
git_user_mail=`git config user.email`
branch_name="local"
remote_alise=`git remote | tail -1`
remote_url=""
is_init=0
noupdate_filename=".gitignore"
if [ -r "./.git" ]
then
is_init=1
fi
if [ ! $git_user_name ]
then
echo "请输入git user.name:"
read git_user_name
echo "请输入git user.email:"
read git_user_mail
fi
if [ $remote_alise ]
then
remote_url=`git remote get-url --push $remote_alise`
else
echo "创建git别名,请输入别名:"
read remote_alise
echo "请输入别名对应的url(ssh):"
read remote_url
fi
git config --global user.name $git_user_name
git config --global user.email $git_user_mail
git init
if [ ! -e $noupdate_filename ]
then
echo -e "*.noupload/\n*.noupload\n*.noupload.sh" > $noupdate_filename
fi
git remote add $remote_alise $remote_url
git pull $remote_alise master
git branch $branch_name
git checkout $branch_name
echo "Status:"
git status
echo "Branch:"
git branch -v
echo "Remote:"
git remote -v
if [ $is_init == 0 ]
then
echo "是否进行首次提交(Y/N)?:"
read ch
if [ $ch == "Y" ] || [ $ch == 'y' ]
then
git add ./*
git commit -m "First commit"
git push $remote_alise $branch_name
fi
else
echo "是否进行提交(Y/N)?"
read ch
if [ $ch == "Y" ] || [ $ch == 'y' ]
then
git add ./*
echo "请输入提交说明:"
read des
git commit -m des
git push $remote_alise $branch_name
fi
fi