二 git 安装
- [root@Ansible ~]#yum -y install git
- [root@Ansible ~]# git --version
- git version 1.7.1
- [root@Ansible ~]# cp /usr/share/doc/git-1.7.1/contrib/completion/git-completion.bash /etc/bash_completion.d/
- [root@Ansible ~]# source /etc/bash_completion.d/git-completion.bash
添加用户和邮箱
- [root@Ansible ~]# git config --global user.name "carol"
- [root@Ansible ~]# git config --global user.email lijiayi@uplooking.com
新建存储目录 (工作平台)
[root@Ansible /]# mkdir /myproject
初始化工作平台
- [root@Ansible myproject]# git init
- Initialized empty Git repository in /myproject/.git/
第一次提交文件
1) 先在工作区生成一个文件
- [root@Ansible myproject]# echo hello>welcome.txt
- [root@Ansible myproject]# ls
- welcome.txt
- [root@Ansible myproject]# cat welcome.txt
- hello
2) 为了将这个新建立的文件添加到版本库, 需要执行以下指令
- [root@Ansible myproject]# git add welcome.txt
- [root@Ansible myproject]# git commit -m "frist"
- [master (root-commit) ff38d0d] frist
- 1 files changed, 1 insertions(+), 0 deletions(-)
- create mode 100644 welcome.txt
1)git diff: 用来显示工作区和暂存区文件的差异
- [root@Ansible myproject]# echo test>>welcome.txt
- [root@Ansible myproject]# ls
- welcome.txt
- [root@Ansible myproject]# cat welcome.txt
- hello
- test
- [root@Ansible myproject]# git diff welcome.txt
- diff --git a/welcome.txt b/welcome.txt
- index ce01362..b2b9cc9 100644
- --- a/welcome.txt
- +++ b/welcome.txt
- @@ -1 +1,2 @@
- hello
- +test
2)git status: 用来查看改过的内容
- [root@Ansible myproject]# git status
- #on branch master
- #Changed but not updated:
- #(use "git add <file>..." to update what will be committed)
- #(use "git checkout -- <file>..." to discard changes in working directory)
- #modified: welcome.txt
- #no changes added to commit (use "git add" and/or "git commit -a")
3)git log: 用来查看历史提交的日志
- [root@Ansible myproject]# git log
- commit ff38d0d40f471d840c49d9a1cba007763e5f6efa
- Author: carol <lijiayi@uplooking.com>
- Date: Mon Mar 26 13:51:50 2018 +0800
来源: http://www.bubuko.com/infodetail-2544115.html