1.配置git
1.鼠标右键文件夹(准备提交至git仓库的文件所在文件夹)点击Git Bash Here 打开git
2.配置用户名和邮箱
$ git config --global user.email "你的邮箱"
$ git config --global user.name "你的用户名"
2.上传至远程仓库
//在当前目录新建一个Git代码库
$ git init
//添加当前目录的所有文件到暂存区
$ git add .
//添加当前目录的update.sql文件到暂存区
$ git add update.sql
//提交暂存区到仓库区
$ git commit -m “提交信息”
//增加一个新的远程仓库,并命名 (URL是刚刚保存的URL)
$ git remote add origin http://gitea.33cloudsoft.com:3000/chengguangxin/chengguangxin-repository.git
//上传本地指定分支到远程仓库
$ git push origin master
git查看结果
3.常用命令
//提交
$ git add update.sql
$ git commit -m “提交信息”
$ git push origin master
//拉取
$ git pull origin master
//查看记录
$ git log
//回滚代码
$ git reset --hard [commit的编号]
注意:此时只是本地仓库回滚,根据情况判断是否提交至远程仓库,提交时需进行强制提交操作进行回滚
强制提交
$ git push -f 远程仓库别名 分支名称
//暂存区中删除文件
$ git rm update.sql
//单独提交update.sql文件
$ git commit update.sql -m "commit message"
//提交暂存区所有文件
$ git commit -am "commit message"
//查看本地工程所有分支
$ git branch
//查看远程仓库所有分支
$ git branch -r
//查看所有分支
$ git branch -a