标签:git
单机上使用gityum install git -y
mkdir -p /git/local
cd /git/local
git init
ls -a //多了这样的目录. .. .git
echo "study-linux-seccesful" > git-test.file
git add git-test.file
git commit -m "add git-test.file" //会有一段提示
git config --global user.name "apeng"
git config --global user.email apeng@apenglinux.com
echo "win-live" >> git-test.file
git add git-test.file
git commit -m "add git-test.file.again"
git status
修改测试文件,再执行 git status //提示要提交
git diff git-test.file //与原文件进行比较
git add git-test.file
git commit -m "change-git-test.file"
vim git-test.file
git add git-test.file;git commit -m "modify git-test.file"
[root@localhost local]# git log
commit ff5a97862cdfd4e8ff134e24cb6fbf38e5990492
Author: apeng <apeng@apenglinux.com>
Date: Fri Mar 23 19:18:14 2018 +0800
modify git-test.file
commit 2c9b30ee6ca18ef37423e0e43b9cd5389c88420d
Author: apeng <apeng@apenglinux.com>
Date: Fri Mar 23 19:14:10 2018 +0800
change-git-test.file
commit b67b1c546ce97175600b2d5e39e978db008b9c99
Author: apeng <apeng@apenglinux.com> //记录在/root/.gitconfig这个文件中
Date: Fri Mar 23 19:05:36 2018 +0800
add git-test.file.again
commit 8f2669bf323dccf39dcd88be35db9a00eaf96844
Author: root <root@localhost.localdomain>
Date: Fri Mar 23 18:54:55 2018 +0800
add git-test.file
[root@localhost local]# git log --pretty=oneline
ff5a97862cdfd4e8ff134e24cb6fbf38e5990492 modify git-test.file
2c9b30ee6ca18ef37423e0e43b9cd5389c88420d change-git-test.file
b67b1c546ce97175600b2d5e39e978db008b9c99 add git-test.file.again
8f2669bf323dccf39dcd88be35db9a00eaf96844 add git-test.file
git reset --hard 8f2669bf323dccf39 //回滚到“add git-test.file”
[root@localhost local]# git log --pretty=oneline //查看日志
8f2669bf323dccf39dcd88be35db9a00eaf96844 add git-test.file
rm -f git-test.file //删除本地的测试文件
git checkout -- git-test.file //从git仓库中还原文件
标签:git
原文地址:http://blog.51cto.com/13480443/2090443