配置git用户名和邮箱
git config --global user.name "Your Name"
git config --global user.email you@example.com
初始化版本库
git init
添加文件到版本库(从工作区状态 到 暂存区状态)
git add -- filename
git commit -m "对于本次提交的备注"
查看仓库状态
git status
撤销对文件的改动
git checkout -- filename
撤销 暂存区 中文件变动的记录
git reset HEAD filename
查看git日志
git log
恢复到之前的某一次提交之后的状态
git reset --hard 1efd0f7233cf89a185c49939bccac3bd65d75a65 (使用git log命令可以查找到每一次操作对应的hard值)
标签管理
分支管理
创建新的分支:
查看分支:git branch
切换分支
合并分支
git工作流
把本地的git仓库添加到远程的github仓库
…or create a new repository on the command line
echo "# 555" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/mydre/555.git
git push -u origin master
…or push an existing repository from the command line
git remote add origin https://github.com/mydre/555.git
git push -u origin master