首先感谢廖雪峰老师的无私奉献, 让我能系统地学习 Git.
- 初始化一个 Git 仓库
git init
- 修改配置, [用户名, 邮箱]
git config --global user.name "your name"
git config --global user.email "your email"
- 把文件添加到版本库
git add readme.txt
- 把文件提交到版本库
git commit -m "this is my first commit"
- 查看版本库的状态
git status
- 查看文件被修改的地方
git diff readme.txt
- 历史记录
git log
git log --pretty=oneline (注释: 如果想要单行输出)
- 版本回退
HEAD 表示当前版本, HEAD^ 表示上一个版本,
HEAD^^ 表示上上个版本, HEAD~100 表示上100个版本
git reset --hard HEAD^ (注释: 表示回退到上一个版本)
git reset --hard <版本号> (注释: 表示回退到指定版本号的版本)
- 查看操作历史
git reflog
网友评论