Git的安装与配置
一、Linux下安装Git
判断Linux下是否已经安装了git,输入命令git看到如下信息则说明,git还未安装
[yunns@bogon Desktop]$ git bash: git: command not found...
1、下载git,按照提示下一步,完成安装即可。(注意yum要在root用户下使用)
[yunns@bogon Desktop]# yum install git
...
...
Installed:
git.x86_64 0:1.8.3.1-6.el7_2.1
Dependency Installed:
perl-Error.noarch 1:0.17020-2.el7 perl-Git.noarch 0:1.8.3.1-6.el7_2.1
perl-TermReadKey.x86_64 0:2.30-20.el7
Complete!
2、查看git版本
[root@bogon Desktop]# git --version
git version 1.8.3.1
二、配置Git
安装完git后,还需进行配置你的信息
[root@bogon Desktop]# git config --global user.name "yunns"
[root@bogon Desktop]# git config --global user.email "406811520@qq.com"
三、创建版本库
1、新建文件夹git-repository
[root@bogon Desktop]# mkdir git-repository
2、初始化git仓库
[root@bogon git-repository]# git init
Initialized empty Git repository in /home/yunns/Desktop/git-repository/.git/
Initialized empty Git repository in /home/yunns/Desktop/git-repositroy/.git/
表示在/home/yunns/Desktop/git-repository/位置,创建好了一个git的仓库,可通过ls -ah查看.git文件
[root@bogon git-repository]# ls -ah . .. .git
四、测试,添加一个文件到git仓库
1、新建文件readme.txt
[root@bogon git-repository]# vi readme.txt
Git is a free and open source version control system.
2、使用命令git add添加文件到仓库(可以通过git add 多个文件或文件夹到仓库,然后一起提交)
[root@bogon git-repository]# git add readme.txt
3、使用命令git commit 提交文件,-m后可添加你的提交信息
[root@bogon git-repository]# git commit -m"2016-03-26 20:34 submit 2files for yunns"
[master (root-commit) fc06f54] 2016-03-26 20:34 submit 2files for yunns
1 file changed, 2 insertions(+)
create mode 100644 readme.txt
好了,今天的笔记就到这里了,我也是初学者,有不足之处还请前辈多多指教!