Git:分布式版本控制工具
图(1):说明本地的代码与远程仓库(即GIT服务器上)代码是完整的镜像
图(2):主要说明以下4点:
(1)git fetch:是将GIT服务器(远程仓库)上代码更新到本地的远程分支上;
(2)GIT PULL:是将GIT服务器(远程仓库)上代码更新到本地的远程分支上同时将更新的代码合入到本地当前分支上;
(3) GIT COMMIT:是将本地目录下的改动内容提交到本地仓库的分支上;
(4)GIT PUSH:是将本地仓库分支上的改动提交到远程仓库中
以下添加远程仓库及本地仓库操作实例:
1、在GIT服务器上创建仓库:(在10.192.3.2服务器上操作,工作目录: /home/git)
创建项目: mkdir hspvirtual
chown -R apache:apache hspvirtual
生成仓库:cd hspvirtual
git init –bare
2、在本地进行远程仓库Clone(即代码拉取,生成本地仓库): https://ahyu@10.192.3.2/git/hspvirtual
“C:\Program Files\Git\bin\git.exe” clone -v –recurse-submodules –progress “https://ahyu@10.192.3.2/git/hspvirtual” “C:/Users/ahyu/work/git/hspvirtual”
Cloning into ‘C:/Users/ahyu/work/git/hspvirtual’…
warning: You appear to have cloned an empty repository.
Checking connectivity… done.
Done
注:对应GIT工具是的Clone操作
3、拉取远程仓库代码(即GIT FETCH)
“C:\Program Files\Git\bin\git.exe” fetch –progress “–all”
Fetching origin
Done
- push本地仓库代码至远程仓库:(即GIT PUSH)
“C:\Program Files\Git\bin\git.exe” push –recurse-submodules=check –progress “origin” refs/heads/master:refs/heads/master
Counting objects: 21, done.
Delta compression using up to 4 threads.
Total 21 (delta 0), reused 0 (delta 0)
To https://ahyu@10.192.3.2/git/hspvirtual
- [new branch] master -> master
Done
注:使用工具时,提交功能:GIT COMMIT, 推送功能:GIT PUSH
- [new branch] master -> master