Git教程_1

Git快速上手

Git是一个分布式的版本控制系统,类似于多人可共同修改文件的一个平台
1
2
3
4
#Centos上下载源文件后解压,进入文件夹
sudo su
./config
make && make install

即安装成功

配置Git

1
2
3
4
5
#创建一个文件夹来作为Git仓库
mkdir my_git
cd my_git
#将此目录变成一个Git仓库
git init

使用Git

1
2
3
4
5
6
7
8
#将在创建好的git目录下的文件添加至仓库
git add <filename1>
git add <filename2>
...
#将此文件提交至仓库
git commit -m “<remarks>”
#再次对已提交仓库的文件进行修改后提交命令:
git status

$ git status
On branch master
Changes not staged for commit:
(use “git add …” to update what will be committed)
(use “git checkout — …” to discard changes in working directory)

modified: readme.txt

no changes added to commit (use “git add” and/or “git commit -a”)

1
2
3
4
5
6
7
8
#查看修改内容
git diff <filename>
#确认好了要提交后重复一开始的添加提交步骤
#添加 git add #提交 git commit

#每一次commit就相当于保存了一张快照
#查看之间所有修改的快照片
git log -[pretty]