gitHub-读书笔记1
2016-05-14 21:13
330 查看
DemodeMacBook-Pro:~ Demo$ mkdir git-tutorial DemodeMacBook-Pro:~ Demo$ cd git-tutorial DemodeMacBook-Pro:git-tutorial WengFe$ git init Initialized empty Git repository in /Users/WengFe/git-tutorial/.git/
初始化创建一个git仓库, 执行 git init 命令,生成一个.git目录,里面存储管理当前目录内容所需的仓库数据。我们将此目录的内容称之为‘附属于该仓库的工作数’
DemodeMacBook-Pro:git-tutorial WengFe$ git status On branch master Initial commit nothing to commit (create/copy files and use "git add" to track) DemodeMacBook-Pro:git-tutorial WengFe$ touch README.mdDemodeMacBook-Pro:git-tutorial WengFe$ git status On branch master Initial commit Untracked files: (use "git add <file>..." to include in what will be committed) README.md nothing added to commit but untracked files present (use "git add" to track)
touch 命令是向当前git库添加文件, git status 是常用的查看当前库状态 命令
DemodeMacBook-Pro:git-tutorial WengFe$ git status On branch master Initial commit Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: README.md DemodeMacBook-Pro:git-tutorial WengFe$ git rm -f README.md rm 'README.md' DemodeMacBook-Pro:git-tutorial WengFe$ git status On branch master Initial commit nothing to commit (create/copy files and use "git add" to track)
> DemodeMacBook-Pro:git-tutorial WengFe$ git rm -f README.md
git rm -f (filename) 删除文件
vim(filename) 修改文件内容
vim中修改文件内容 按i开始插入字符,按esc退出编辑模式 输入冒号,输入wq 然后回车,w为保存 q为退出
+ this is a question. Who am i?
上图为保存在README.md中的信息
DemodeMacBook-Pro:git-tutorial WengFe$ git diff diff --git a/README.md b/README.md index eb1ae45..7a3cc52 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ -... ++ this is a question. +Who am i?
git diff 查看工作树和暂存区的文件区别
DemodeMacBook-Pro:git-tutorial WengFe$ git add README.md DemodeMacBook-Pro:git-tutorial WengFe$ git diff HEAD diff --git a/README.md b/README.md index e69de29..7a3cc52 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,2 @@ ++ this is a question. +Who am i?
git diff HEAD 向暂存区提交修改的文件,查看工作树与最新提交的差别
DemodeMacBook-Pro:git-tutorial WengFe$ git commit -m "a question" [master 300a38c] a question 1 file changed, 2 insertions(+) DemodeMacBook-Pro:git-tutorial WengFe$ git log commit 300a38c4034e94f1934fd9de31b6a2acc4bc5687 Author: name <name@example.com> Date: Sat May 14 20:18:46 2016 +0800 a question commit fdcb93177f25bf1ca3e37a2b0a1cb98e69159eae Author: name <name@example.com> Date: Sat May 14 19:57:00 2016 +0800 First commit
提交本次的修改文件到工作树(git库?) 并查看日志 是否成功
相关文章推荐
- 代码编写篇
- google hacking搜索语法总结
- [Java] 贪吃蛇 V1.0
- 深入理解java内存模型(三)——顺序一致性
- Java加密技术——BASE64与单向加密算法MD5、SHA、MAC
- GOICE项目初探
- 深入理解java内存模型(二)——重排序
- Java 获取当前时间
- C# 利用反射动态将字符串转换成属性对应的类型值
- 深入理解java内存模型(一)——基础
- java hdu2012素数判定
- faster_rcnn c++版本的 caffe 封装,动态库(2)
- c++中string类成员函数的总结
- php 数字转换大写汉字
- golang slice 切片原理
- java多线程系列5-死锁与线程间通信
- Java中的锁
- FTP 权限的修改 之CuteFTP问题
- Semaphore
- 第7周 C语言程序设计(新2版) 各类位运算符定义