1.git init
2. git add .
3. git commit -m "first time "
4.git remote add origin git@gitee.com:xxxxx/xxxxx.git
5.git push -u origin “master”
常用命令
1.从远程仓库克隆项目到本地
git clone <项目地址 > # https/ssh 地址皆可以
1
2.初始化本地仓库.
git init # 创建本地仓库
1
3.本地仓库与远程仓库关联.
git remote add <仓库名> <仓库地址> # 仓库名自定义 例如:origin
1
4.查看仓库名.
git remote # 查看远程仓库的仓库名,加-v 查看仓库名和地址
1
5.更换远程仓库地址.
git remote ser-url <仓库名> <仓库地址> #
1
6.将文件添加添加到暂存区.
git add . # . 代表所有,可以指定为具体文件
1
7.将暂存区中的文件提交到本地仓库.
git commit -m “<备注说明>” #
1
8.查看所有分支.
git branch # 查看本地分支,加-a查看本地分支和远程分支,结果列表中前面标*标识当前使用分支.
1
9.创建分支.
git branch <分支名称 > #
1
10.切换分支.
git checkout <分支名称> #
1
11.将本地仓库的文件推动到远程仓库.
git push <仓库名> <分支名称> # 推送时建议先(pull)更新一下
1
12.将远程仓库中跟新到本地.
git pull <仓库名> <分支名称> #
1
13.修改远程仓库名称.
git remote rename <旧名称> <新名称> #
1
14.查看提交记录
git log #
1
15.回滚提交
#Reset会把后面提交的记录直接删掉
git reset --hard [commit hash] # 例如:git reset --hard 7b8bcaa0b02959126b923fe554824fa9df1dfd87
1
2
16.分支合并到主分支上
git merge <分支名称>
!!!遇到提交错误可以查看项目所在位置 删除.git文件重新执行命令