这样的场景经常遇到,所以总结一下流程然后可以做一个自动化的脚本工具提高操作效率
- 码云新建一个 public repository
- 本地使用 git clone url 下载新建仓库的样板基础代码
- 将原来的代码拷贝到下载代码文件夹的路径下
- 添加文件
- 提交
- 添加用户名和邮箱
- push
自动化脚本如下:
#########################################################################
# File Name: upload.sh
# Author: Kent Lee
# mail: kent1411390610@gmail.com
# Created Time: Fri May 4 19:46:49 2018
#########################################################################
#!/bin/bash
if [ $# != 4 ]
then
echo "Usage: change to an empty directory and execute sh upload.sh <localFilePath> <gitUrl> <emailForThisGit> <nameForThisGit> "
exit 1
fi
git clone $2 #get repository from git
git config user.email "$3" #tell git who u r
git config user.name "$4"
mv $1 .
git add . #add to upload
git commit -m "$5" #commit
git push -u origin master #push
if [ $? = 1 ]
then
echo "congratulations"
exit 1
fi