Git - 初始化项目

115 阅读1分钟

1、直接 clone

// 获取全部分支、记录
git clone <url>

// 常用参数
// 1、-b:指定分子
// 2、--depth:10  从最近10次提交开始克隆
git clone -b dev --single-branch --depth 1 https://gitee.com/mzynet/1111.git

2、本地无项目

mkdir project // 创建项目目录名称

cd project // 进入项目目录

git init // 初始化 git

touch index.js // 创建 index.js 文件

git add README.md  // 将"工作区"代码存入"暂存区"

git commit -m "first commit" // 将"暂存区"代码存入"版本库"

git remote add origin https://gitee.com/mzynet/project.git // 当前仓库添加远程仓库地址

git push -u origin "master" // 首次提交代码

3、本地有项目

// 查看远程仓库地址
git remote -v

// 新增仓库地址
git remote add origin https://gitee.com/mzynet/repo.git

// 修改仓库地址
git remote set-url origin https://gitee.com/mzynet/333.git

git push -u origin "master"