Git基础-记录每次更新到仓库中-上
来源:互联网 发布:会展中心设计方案 网络 编辑:程序博客网 时间:2024/05/17 21:40
概述:
版本控制就是文件跟踪记录的集合,理解每一次记录改变过程
工作目录的每个文件只有两种状态:已跟踪(表示属于git管辖范围)和未跟踪(git未接管范围)
初次克隆都是未修改已跟踪(这里修改是相对于本地)
我们以上次导入的工程为例进行演示如何操作grit,首先需要切换到工程目录下(grit目录下)
1.检查当前文件的状态:
语法:
$ git status
这是工程的路径~/表示当前用户下
Administrator@USER-20170424ZG MINGW64 ~/grit (master)$ git statusOn branch masterYour branch is ahead of 'origin/master' by 8 commits. (use "git push" to publish your local commits)nothing to commit, working tree clean总结:master是我们默认的分支,by 8 commits刚开始修改了提交8次,如果是初次的话这是没有的
2.开始新建文件并写入helloWorld字符串
方式一:用 $ echo 'helloWorld' > Hello (就是把‘helloWorld放入Hello文件中’)
方式二:用$ vim Hello, 然后它会弹出文本编辑,按i,输入文字helloWorld , 按Esc(退出编辑模式)按 :wq! (保存退出,注意前面的冒号也是要的)
采用第一种方式:
Administrator@USER-20170424ZG MINGW64 ~/grit (master)$ echo 'helloWorld' > HelloAdministrator@USER-20170424ZG MINGW64 ~/grit (master)$ git statusOn branch masterYour branch is ahead of 'origin/master' by 8 commits. (use "git push" to publish your local commits)Untracked files: (use "git add <file>..." to include in what will be committed) Hellonothing added to commit but untracked files present (use "git add" to track)总结:这时候我们新增加文件是未跟踪,就是还不属于git管辖
2.跟踪新文件:
语法:
$ git add 文件名
Administrator@USER-20170424ZG MINGW64 ~/grit (master)$ git add Hellowarning: LF will be replaced by CRLF in Hello.The file will have its original line endings in your working directory.Administrator@USER-20170424ZG MINGW64 ~/grit (master)$ git statusOn branch masterYour branch is ahead of 'origin/master' by 8 commits. (use "git push" to publish your local commits)Changes to be committed: (use "git reset HEAD <file>..." to unstage) new file: Hello总结:现在文件变成暂存状态,保存在暂存区
3.暂存已修改文件
首先查看我们的文件:
语法:
$ lltotal 59drwxr-xr-x 1 Administrator 197121 0 六月 6 21:41 '~'/-rw-r--r-- 1 Administrator 197121 2467 六月 6 20:08 API.txt-rw-r--r-- 1 Administrator 197121 2964 六月 6 20:08 benchmarks.rb-rw-r--r-- 1 Administrator 197121 973 六月 6 20:08 benchmarks.txtdrwxr-xr-x 1 Administrator 197121 0 六月 6 20:08 examples/-rw-r--r-- 1 Administrator 197121 3632 六月 6 20:08 grit.gemspec-rw-r--r-- 1 Administrator 197121 11 六月 7 09:22 Hello-rw-r--r-- 1 Administrator 197121 2589 六月 6 21:10 History.txtdrwxr-xr-x 1 Administrator 197121 0 六月 6 20:08 lib/-rw-r--r-- 1 Administrator 197121 1106 六月 6 20:08 LICENSE-rw-r--r-- 1 Administrator 197121 1591 六月 6 20:08 PURE_TODO-rw-r--r-- 1 Administrator 197121 2412 六月 6 20:08 Rakefile-rw-r--r-- 1 Administrator 197121 13 六月 6 21:34 README-rw-r--r-- 1 Administrator 197121 6792 六月 6 20:08 README.mddrwxr-xr-x 1 Administrator 197121 0 六月 6 20:08 test/-rw-r--r-- 1 Administrator 197121 39 六月 6 20:08 VERSION.yml以修改History.txt 文件为例,保存退出
== 0.7.0 / 2008-01-07== 0.7.0 / 2008-01-07 Hello World输入 git status
$ vim History.txtAdministrator@USER-20170424ZG MINGW64 ~/grit (master)$ git statusOn branch masterYour branch is ahead of 'origin/master' by 8 commits. (use "git push" to publish your local commits)Changes to be committed: (use "git reset HEAD <file>..." to unstage) new file: HelloChanges not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: History.txt将History.txt加入暂存区使用git add History.txt
$ git add History.txtAdministrator@USER-20170424ZG MINGW64 ~/grit (master)$ git statusOn branch masterYour branch is ahead of 'origin/master' by 8 commits. (use "git push" to publish your local commits)Changes to be committed: (use "git reset HEAD <file>..." to unstage) new file: Hello modified: History.txt4.状态简览
语法 git status -s (s是short的简写)
Administrator@USER-20170424ZG MINGW64 ~/grit (master)$ git status -sA HelloM History.txt总结:A:新增文件 M:修改文件
时间有限,还有一部分下回写
阅读全文
0 0
- Git基础-记录每次更新到仓库中-上
- 2.2 Git 基础 - 记录每次更新到仓库
- 2.2 Git 基础 - 记录每次更新到仓库
- 2.2 Git 基础 - 记录每次更新到仓库
- 2.2 Git 基础 - 记录每次更新到仓库
- 2.2 Git 基础 - 记录每次更新到仓库
- Git---记录每次更新到仓库--下
- 记录每次更新到本地git仓库
- 【Git】记录每次更新到本地仓库
- 记录每次更新到仓库
- 【Git 学习笔记】2.2 - 记录每次更新到仓库
- 【Git 学习笔记】2.2 - 记录每次更新到仓库
- git学习——记录每次更新到仓库
- Git基础-提交更新到仓库(二)
- GIT 版本控制软件的常用命令记录每次更新到仓库 现在我们手上已经有了一个真实项目的 Git 仓库,并从这个仓库中取出了所有文件的工作拷贝。接下来,对这些文件作些修改,在完成了一个阶段的目标和使用方法
- Git更新远程仓库代码到本地
- Git更新远程仓库代码到本地
- git fetch 更新远程仓库到本地
- kotlin 函数(一)
- 对三层和MVC的认识过程
- 【Python】8“函数的参数“
- OpenGL 入门基础教程 —— 键盘和鼠标响应
- java利用hashcode判断对象
- Git基础-记录每次更新到仓库中-上
- Java中的反射机制
- Go队列和堆栈
- Markdown转HTML之Node篇
- Android ToggleButton(开关)
- javascript 继承
- java的三大特性
- Java面向对象的三大特性
- 消息队列应用场景