git的三个区
工作区(working tree): 本地编辑器
暂存区(index):git add操作后进入暂存区,可用git status查看
本地仓库(repository):git commit 后进入本地仓库
回退到指定版本
#查看提交日志
git reflog
#回退指定版本
git reset hard <哈希ID>
上传到远程仓库
git add .
git commit -m "提交信息"
git push
或者
git push origin master
配置git
#查看配置信息
git config --list
#查看用户名与邮箱
git config user.name
git config user.email
#配置全局用户与邮箱
git config --global user.name "用户名"
git config --global user.email "邮箱"
#修改当前服务/项目Git用户名与邮箱
git config user.name "用户名"
git config user.email "邮箱"
#使用git命令修改“commit message”同时重置当前Commit的user/email
git commit --amend --reset-author
#协同开发的场景下,查看自己commit的git记录
git log --author="你的用户名"
在本地创建分支
#在本地基于master创建新分支
git checkout -b <new_branch> master
#将本地分支推送到远程
git push -u origin <local_branch_name>
#删除本地分支
git branch -d <branch_name>