将现有代码上传码云 gitee

2018-05-04  本文已影响0人  李2牛

这样的场景经常遇到,所以总结一下流程然后可以做一个自动化的脚本工具提高操作效率

  1. 码云新建一个 public repository
  2. 本地使用 git clone url 下载新建仓库的样板基础代码
  3. 将原来的代码拷贝到下载代码文件夹的路径下
  4. 添加文件
  5. 提交
  6. 添加用户名和邮箱
  7. 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

上一篇 下一篇

猜你喜欢

热点阅读