参考资料
本文内容参考了廖雪峰老师的博文,并做了适当整理,方便大家查阅。
常用命令
仓库初始化 - git init
1 | git init |
我们新建一个文本文件readme.txt
1
2Git is a distributed version control system.
Git is free software.
将文件添加到仓库中 - git add
1 | git add . |
将文件提交到仓库 - git commit
1 | git commit -m "wrote a readme file" |
查看仓库状态 - git status
1 | git status |
对比文件区别 - git diff
对文件内容进行简单修改并保存,这时还未提交(commit
)到仓库,如果这时我们希望对比一下自从上次提交后,该文件发生了哪些变化,可以用git diff
命令实现。1
git diff readme.txt
注:
diff
比较的是当前未提交(commit
)的版本跟上一个版本之间的差别。一旦commit
到仓库,就无法比较了。