Git-本地库的基本操作
Git-本地库的基本操作
-
初始化本地库
1
git init
-
查看本地库状态
1
git status
1
2
3On branch master
No commits yet
nothing to commit (create/copy files and use "git add" to track) -
查看当前工作区文件和暂存区文件之间的差异
1
git diff
-
将工作区文件添加到暂存区
1
2git add <文件名> # 将工作区某文件添加到暂存区
git add . # 将工作区所有文件添加到暂存区 -
将暂存区中的某文件删除
1
git rm --cached <文件名>
-
移动或重命名工作区文件
1
git mv <文件名> <新文件名>
-
将暂存区的文件提交到本地库
1
git commit -m "<日志信息>" <文件名>
-
丢弃工作区的修改,使用暂存区的内容代替工作区
1
git checkout -- <文件名>
参考资料
Comment