git和hg (mercurial)的一些基本用法

还是快毕业时到公司实习那时开始接触版本管理工具,当时及前两年都是一直用svn来做SCM工具,而最近这一年做Open Source,主要用git和mercurial (hg)来做SCM工具了。其实,现在看来,其实作为非专业SCM人员,作为一个Developer或者QA,多数情况下只需要简单了解其中原理和基本命令即可。本文主要根据git和mercurial官网的Quick Start简单修改一下,这些东西应对我目前偶尔涉及到的基本SCM相关的工作已经足够了。

本文是介绍git和mercurial (hg)的使用,如果想了解svn,可以看我曾经的一篇博客:
svn资料: http://renyongjie668.blog.163.com/blog/static/16005312010612101745810/

Git Quick Start

Cloning and Creating a Patch

$ git clone git://github.com/git/hello-world.git

$ cd hello-world

$ (edit files)

$ git add (files)

$ git commit -m 'Explain what I changed'  #(local)

$ git format-patch origin/master

$ git push           #(remote)

$ git status


Creating and Commiting

$ cd (project-directory)

$ git init

$ (add some files)

$ git add .

$ git commit -m 'Initial commit'

$ git status

 

Mercurial (hg) Quick Start

Clone a project and push changes

$ hg clone http://selenic.com/repo/hello

$ cd hello

$ (edit files)

$ hg add (new files)

$ hg commit -m ‘Explain what I changed’

$ hg push

$ hg status

Create a project and commit

$ hg init (project-directory)

$ cd (project-directory)

$ (add some files)

$ hg add

$ hg commit -m 'Initial commit'

$ hg status

 

reference links:

http://git-scm.com/

http://mercurial.selenic.com/

master

Stay hungry, stay foolish.

One Comment

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

*