赞
踩
目录
在linux发布后,linux不断壮大,因为是开源的原因,所以很多人把源码文件发给linux的作者整理,当然是手工整理,后来linux代码库就很大,无法手工整理如此多的文件,但是linux作者不想使用subversion版本控制等等原因。后来一个商业公司将其的分布式版本控制授权给linux开发社区免费使用。但是linux社区的黑客有点多,samba的开发者试图破解商业公司的分布式版本,所以商业公司就收回了。
然后基于C语言的Git分布式就上线了,并上传了linux的源码。
1:开源
2:关注文件数据整体变化,SHA-1加密
已提交、已修改、已暂存
- [root@www ~]# yum install -y git
-
- ......
-
- 更新完毕:
- git.x86_64 0:1.8.3.1-14.el7_5
-
- 作为依赖被升级:
- perl-Git.noarch 0:1.8.3.1-14.el7_5
-
- 完毕!
/etc/gitconfig、~/.gitconfig、~/.config/git/config、工作目录/.git/config(当然不一定都有这些文件,反正小博主没有)
1:配置个人用户名和电子邮箱。Git提交时会引用,随着更新内容永久存储在log中
- [root@www etc]# git config --global user.name "Linux Git"
- [root@www etc]# git config --global user.email "root@youxiang.com"
2:设置vim为默认文本编辑器
[root@www etc]# git config --global core.editor vim
查询上面2项是否配置完成
- [root@www etc]# git config --list
- user.name=Linux Git
- user.email=root@youxiang.com
- core.editor=vim
1:创建本地工作目录
创建Git文档并初始化成Git的工作目录
- [root@www ~]# mkdir Git文档
- [root@www ~]# ls
- Git文档 公共 模板 视频 图片 文档 下载 音乐 桌面
- [root@www ~]# cd Git文档/
- [root@www Git文档]# ls
- [root@www Git文档]# git init
- 初始化空的 Git 版本库于 /root/Git文档/.git/
Git下多为文件,不能判断图片、视频、可执行命令等
2:写一个新文件并提交
[root@www Git文档]# echo "你好!世界" >> world.txt
加到暂存区:
[root@www Git文档]# git add world.txt
修改本地文件内容:
[root@www Git文档]# echo "嗯,你好" >> world.txt
将暂存区的文件提交到Git版本仓库:
- [root@www Git文档]# git commit -m "提交你好世界文件"
- [master(根提交) b6cb176] 提交你好世界文件
- 1 file changed, 1 insertion(+)
- create mode 100644 world.txt
查询工作目录的状态:
- [root@www Git文档]# git status
- # 位于分支 master
- # 尚未暂存以备提交的变更:
- # (使用 "git add <file>..." 更新要提交的内容)
- # (使用 "git checkout -- <file>..." 丢弃工作区的改动)
- #
- # 修改: world.txt
- #
- 修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
提示:未提交——不是已经提交了吗?
对比本地文件和Git版本数据库中的文件:
- [root@www Git文档]# git diff world.txt
- diff --git a/world.txt b/world.txt
- index 0ac89c2..83e1ccc 100644
- --- a/world.txt
- +++ b/world.txt
- @@ -1 +1,2 @@
- 你好!世界
- +嗯,你好
那是因为提交的是暂存区的文件,而本地的文件内容是:嗯,你好,所以对比后提示没有提交文件。所以,修改了本地文件就需要重新提交暂存区,再由暂存区提交到Git版本仓库中。
- [root@www Git文档]# git add world.txt
- [root@www Git文档]# git commit -m "提交新的你好世界文件"
- [master 2a678f1] 提交新的你好世界文件
- 1 file changed, 1 insertion(+)
查询Git版本的状态信息:
- [root@www Git文档]# git status
- # 位于分支 master
- 无文件要提交,干净的工作区
当修改的文件较多的时候,可以选择一次提交所有文件到暂存区
- [root@www Git文档]# git add .
- [root@www Git文档]# git commit -m "提交所有文件"
忽略部分上传的文件
- [root@www Git文档]# touch git.c
-
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。