---
title: "（转）SVN，HG，GIT命令对照"
author: "mlxia"
date: "2010-03-29T13:40:35Z"
tags: []
categories: ["非技术"]
slug: "svn-hg-git"
draft: false
lastmod: "2010-03-29T13:40:35Z"
id: 627183
url: "https://mlxia.iteye.com/blog/627183"
---

## [http://www.1uu2.com/archives/992](http://www.1uu2.com/archives/992)

## [SVN，HG，GIT命令对照](http://www.1uu2.com/archives/992 "Permanent Link to SVN，HG，GIT命令对照")

[liner](http://www.1uu2.com/archives/author/admin/ "liner 发布") 发表于 2009-10-11 21:45 | 来源：[](http://www.1uu2.com/archives/992) | 阅读 635 次

![](http://z.alimama.com/alimamal.php?i=mm_10598618_2190845_8650783&w=&h=62&re=1280x1024&sz=tl_3x5_8&cg=615c59387a51969c5c935439ca39a0aa&prk=83921179&cas=prk&cah=994&caw=1280&ccd=32&ctz=8&chl=1&cja=1&cpl=14&cmm=64&cf=10.0&u=http%3A%2F%2Fwww.1uu2.com%2Farchives%2F992&r=http%3A%2F%2Fwww.google.com.hk%2Fsearch%3Fhl%3Dzh-CN%26newwindow%3D1%26safe%3Dstrict%26q%3Dgit%252Fhg%26meta%3D%26aq%3Df%26aqi%3Dg1g-m2%26aql%3D%26oq%3D%26gs_rfai%3D&sx=157&sy=278&cbw=1263&cbh=2621)

SVN，HG，GIT是三种常见的版本控制系统，本文简单列出一些相似的操作命令。当然，三种系统各有特点，严格的对应关系是没有的。

1，第一次下载，包括源码和版本库：  
svn checkout http://path/to/repo repo\_name  
hg clone http://path/to/repo  repo\_name  
git glone http://path/to/repo repo\_name或者git glone git://path/to/repo repo\_name

2，下载服务器上最新的更新：  
svn update  
hg pull && hg update -C  
git pull

3，检出某个修订版本  
svn checkout -r &lt;rev&gt;  
hg update -C -r &lt;rev&gt;  
git reset –hard -r &lt;rev&gt;

4，新增被跟踪文件  
svn add /path/to/file  
hg add /path/to/file  
git add /path/to/file

4，移除被跟踪文件  
svn rm /path/to/file  
hg remove /path/to/file  
git rm /path/to/file

5，生成补丁  
svn diff  &gt;patch\_file  
hg diff &gt;patch\_file  
git diff &gt;patch\_file

6，提交更改  
svn commit  
hg commit  
git commit

6，查看当前状态  
svn info  
hg status  
git status

7，查看修订记录  
svn log  
hg log  
git log

8，启动服务器  
svnserve -d  
hg serve -p 8002 &  
git daemon –base-path=/path/to/repo –export-all &