git基础

一, git,一个分布式的版本库,是典型的客户端-服务器系统,能有效,快速地处理项目从很小到足够大时的版本管理.画了一个示意图,如下:

二, 版本控制的类别

    a)集中式,开发者之间共用一个仓库,且必须保持联网操作.比如CVS,SVN(subversion).而且,SVN有取代CVS的趋向.

    b)分布式,每个开发者都有一个仓库的完整克隆,每个人都是一个服务器,且可以断网操作,如git, bitkeeper,但是bitkeeper非开源,需要收费的.

三,git工作的简要示意图

      远程服务器:托管在internet上或者其它网络上的项目版本库.

      git仓库:保存所有数据的地方.

      工作区:从仓库中取出的文件,放在本地磁盘中供使用或修改.

      暂存区:一个索引文件,保存了下次将提交的文件的信息列表. 

四, git的访问方式

      git的访问方式有,本地访问,远程访问,web浏览器访问.

      本地访问格式:git clone file:///var/git 

      远程访问格式:git clone root@服务器IP:/var/git

      web访问格式:git clone http://服务器IP/git仓库,以及访问安全地址的https://服务器IP/git仓库.

五, 客户端的一些命令工具

    clone  将远程服务器的仓库克隆到本地

    config 修改git 的配置

    add    添加修改内容到暂存区

    commit   将修改内容提交到本地仓库

    push   推送本地内容到远程服务器

六, 示例,上传一个shell文件到远程服务器

[root@room9pc01 ~]# git clone http://github.com/liusingbon/shell-scripts.git
[root@room9pc01 ~]# cd shell-scripts
[root@room9pc01 ~]# git pull   #下载网络文件内容
[root@room9pc01 ~]# ls    #查看一下
[root@room9pc01 shell-scripts]# cp /home/student/bin/shell/删除某个目录下大小为0的文件.sh  .
[root@room9pc01 shell-scripts]# git add .     #这里的小数点示意当前目录位置
[root@room9pc01 shell-scripts]# git commit -m '删除某个目录下大小为0的文件.sh'
[root@room9pc01 shell-scripts]# git push      #推送数据到远程仓库
Username for 'https://github.com': liusingbon          #输入github网站用户名
Password for 'https://liusingbon@github.com':        #输入github网站的用户密码
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 558 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
remote: This repository moved. Please use the new location:
remote:   https://github.com/liusingbon/shell-scripts.git
To https://github.com/liuabang/shell-scripts
   96914b6..870fe0a  master -> master

结束.  

原文地址:https://www.cnblogs.com/liusingbon/p/10967896.html