标签:Git
一、Git简介1.centos7安装Git
[root@server-1 ~]# yum install -y git
2.查看安装的Git版本
[root@server-1 ~]# git --version
git version 1.8.3.1
3.创建git安装目录并初始化
[root@server-1 ~]# mkdir /data/git/
[root@server-1 ~]# cd /data/git/
[root@server-1 git]# git init
Initialized empty Git repository in /data/git/.git/
初始化后在该目录下会生成.git隐藏目录
[root@server-1 git]# ls -la
total 0
drwxr-xr-x. 3 root root 18 Apr 8 09:07 .
drwxr-xr-x. 5 root root 45 Apr 8 09:05 ..
drwxr-xr-x. 7 root root 119 Apr 8 09:07 .git
[root@server-1 git]# ls .git/
branches config description HEAD hooks info objects refs
4.新建一个test.txt测试文件
[root@server-1 git]# vim test.txt
123abc
把本地test.txt文件添加到git仓库
[root@server-1 git]# git add test.txt
add后必须执行commit才能真正把文件提交到git仓库里
[root@server-1 git]# git commit -m "add new file test.txt"
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account‘s default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got ‘root@server-1.(none)‘)
修改test.txt
[root@server-1 git]# vim test.txt
123abc
456789
[root@server-1 git]# git add test.txt
[root@server-1 git]# git commit -m "add new file test.txt"
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account‘s default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got ‘root@server-1.(none)‘)
查看当前仓库中的状态是否有改动的文件
[root@server-1 git]# git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: test.txt
#
# Changes 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: test.txt
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .test.txt.swp
标签:Git
原文地址:http://blog.51cto.com/liuleis/2095524