分布式版本控制工具学习--Git

     什么是分布式版本控制:

        分布式版本控制 (DVCS) 是一种不需要中心服务器的管理文件版本的方法,但是它也可以使用中心服务器。更改可以被合并到 DVCS 的任何其他用户的系统中,因此可以实现非常灵活的工作流

   DVCS 和集中式版本控制系统的主要差 :

DVCS 和集中式版本控制系统之间有三个关键差异。

第一个差异是, DVCS 通过本地提交支持离线工作,这是由 DVCS 的操作方式决定的。这与集中式版本控制完全不同,集中式版本控制要求通过到中心服务器的连接执行所有操作。这种灵活性让开发人员在任何地方都能够像在办公室中一样轻松地工作,可以一次又一次地进行提交。

第二个差异是 DVCS 比集中式系统更灵活,因为 DVCS 支持许多不同类型的工作流,从传统的集中式工作流到纯粹的特殊工作流,再到特殊工作流和集中式工作流的组合。这种灵活性允许通过电子邮件、对等网络和开发团队喜欢的任何方式进行开发。

第三个差异是 DVCS 比集中式版本控制系统快得多,因为大多数操作在客户机上进行,速度非常快。另外,在需要进行推( push )操作(与另一个节点通信)时,速度也更快,因为两个客户机机器上都有完整的元数据。速度差异相当显著,根据使用本地存储库还是网络存储库, DVCS Subversion 快大约 3-10 倍。

 

目前的分布式版本控制工具: Git Mercurial Bazaar

Git 基础:

(1)     Install Git:

On windows:

(1)     Tortoise Git: http://pixhawk.ethz.ch/wiki/toolchain/git/windows_git_installation

(2)     Msysgit: http://code.google.com/p/msysgit/downloads/list

(3)     Cygwin: http://www.cygwin.com/setup.exe

(2)     Config Git:

关于配置文件:

Windows 系统上, Git 会找寻用户主目录下的 .gitconfig 文件。主目录即 $HOME 变量指定的目录,一般都是 C:/Documents and Settings/$USER 。此外, Git 还会尝试找寻 /etc/gitconfig 文件,只不过看当初 Git 装在什么目录,就以此作为根目录来定位。

--global è ” C:/Documents and Settings/$USER/.gitconfig”

--system è 安装目录 /etc/gitconfig”

 

git config --global user.name "name"

git config --global user.email  [email protected]

git config --global   --list

git config --global color.ui "always"

git config   --global  core.editor   c:/windows/system32/ notepad.exe”

 

(3)     Setup Initial Project Repository:

A.       Create a folder: mkdir MyGit

B.       Init the repository for the project:

cd MyGit

git init

C.       Add a file to the project repository

Make a new file desc

git  add desc => the file will be in the staging area then.

git commit –m “add a new file: desc” => the file will be in the repository then.

git status =>check the status of the working tree.

git  log => check the log info

D.       Branch & Tag & Merge

git branch test_r1.0 master è create a branch test_r1.0 based on the latest of master branch.

git checkout test_r1.0 è switch to branch of test_r1.0 from master branch.

Add a new file “1”on the branch test_r1.0

git add 1

git commit –m “add a new file: 1 on branch test_r1.0”

git tag  TEST_REL_1 test_r1.0 è make a tag on the branch of test_r1.0

git tag MASTER_REL_1 master è make a tag on the branch of master

git checkout test_r1.0

git rebase MASTER_REL_1 è rebase test_r1.0 branch against MASTER_REL_1

git archive –format=zip –prefix=”Master_REL_1” master > Master_REL_1.zip

E.        Work with Remote Repository

git  clone <remote >   [local]

git clone http://github.com/tswicegood/mysite

 

 

深入学习:

(1)     Add Commit:

(1)     Staged changes: Simply changes in your working tree that you want to tell your repository about.

(2)     Staging Area:  A place where set up the commits prior to commit to the repository.

(3)     git  add file |file list

A.       git add file

B.       git add file1 file2 …

C.       git add –i

* ** Commands ***

  1: status 2: update 3: revert    4: add untracked

  5: patch   6: diff          7: quit       8: help

Notes: 1. Status-check the status of the working tree.

             2. update- generate a list of changes to be staged, you should select the change need to be updated.

            3. Revert- generate a list of changes can be reverted, you should select the change need to be reverted.

             4. Add untracked- add untracked files to the staging area.

            5. Patch – You can choose which file or files you want to add

             6. Diff – display the differences of the file in staging area and the repository.

                          

(4)     Commit

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值