常用Git命令
一定要进入目标文件内进行操作,目标文件内如果有.git,不要在进行git init初始化
在git bash中输入命添加 ssh key
$ ssh-keygen -t rsa -C "youremail@example.com"
新建版本库
git init
查询repo状态
git status
查看当前主干下有哪些分支
git branch -a
从github上下载:
git clone git@github.com:fast-cache/fast-cache.git
列出当前文件夹内的文件
ls或者ll
查看修改当前用户名和邮箱
cd fast-cache
git config user.name ['fast-cache']
git config user.email ['fast-cache@github.com' ] 在项目中修改当前git用户名和邮箱,使其和GitHub的一致。
线上库和线下库合并
git pull
提交到GitHub
git add .
git commit -m "first update"
git push origin master
git回滚到某个版本
git reset --hard 某个版本号