Git study notes
来源:互联网 发布:java获取jar包中文件 编辑:程序博客网 时间:2024/06/02 06:12
Git study notes (1)
reference :Liao Xuefeng’s blog
1.preparation
First,install the git,open git-bush.Then you will see a window like CMD,which means you are succeed.Now, you can write something in this black window.
2.new a repository
mkdir learngitcd learngitpwd //show you the current content
then you can use git init
to initate this respository,making it administrable.like this:
$ git initInitialized empty Git repository in /Users/michael/learngit/.git/
3.Add a new file to your repository
Till now,we’ve create a repository.Why not add something to it?Put a readme.txt
file to the content.Then,write something like this in the git-bush:
$ git add readme.txt(file name)
4.write some notes about your modification
When you finishing adding all the files,you can write something as a comment which will be convenient for you or other readers to know what modifications you’ve made this time.Just like this:
$ git commit -m "wrote a readme file"
then you can see something like this
[master (root-commit) cb926e7] wrote a readme file 1 file changed, 2 insertions(+) create mode 100644 readme.txt
Suppose that we have modified readme.txt,we can use git status
order to get the dynamic state about this repository.So you can see:
$ git statusOn branch masterChanges 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: readme.txtno changes added to commit (use "git add" and/or "git commit -a")
5.get the difference after your modification
But if you went vacation for some days,when you came back,you did’t remember what modification you’ve done to this file,you can use git diff
to see the detail.Suppose that the original is
“Git is a distributed version control system.
Git is free software.”
and the second version is
“Git is a distributed version control system.
Git is free software.”
So you can see some sentences like this:
$ git diff readme.txt diff --git a/readme.txt b/readme.txtindex 46d49bf..9247db6 100644--- a/readme.txt+++ b/readme.txt@@ -1,2 +1,2 @@-Git is a version control system.+Git is a distributed version control system. Git is free software.
By the way,these words are highlighted in Git-Bush.So I think it will look better.
Before we add this modified file to the respository,we can use git status
to see the status(this is a good habit).Now you can see:
$ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: readme.txt`git status` tells us that files to be submitted includes `readme.txt`.
Now,we can submit it:
$ git commit -m "add distributed"[master ea34578] add distributed 1 file changed, 1 insertion(+), 1 deletion(-)
At last , we can use git status
again. And it says:
$ git status On branch masternothing to commit (working directory clean)
- Git study notes
- GIT Study Notes
- Git study notes
- git study notes
- study notes
- MySql study notes [1]
- Portlet Study Notes (1)
- IBM Director study notes
- lucene study notes
- lucene study notes (2)
- Legacy Study notes(Servlet)
- C++ Study Notes
- System Architect Study notes
- flex study notes (2)
- scm515 study notes
- Java API Study Notes
- Webkit Timer study notes
- Webkit JNI study notes
- 初学C语言
- markdown编辑器使用心得
- Disruptor 简介
- 直接插入排序
- BZOJ 1854 [Scoi2010]游戏——二分图匹配
- Git study notes
- 腾讯后台开发一面二面纪实
- 【前端-笔记】快乐的sublime编辑器(mac操作版)
- Android Activity四种启动模式
- 达内课程-JAVA八种基本类型
- Winform快捷键小结
- 2.[个人]C++线程入门到进阶(2)----线程同步之信号量(semaphore)
- Android Shape一些新玩法?
- 第 1 章:Web基础技术( Header Field )