IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    Mercurial教程1:入门

    Ivan Cai发表于 2014-11-23 20:38:00
    love 0

    你要做的第一件事就是设置用户名。可以通过编辑或创建~/.hgrc(Windows系统下则是%USERPROFILE%\Mercurial.ini)并加入如下内容

    [ui]
    username = John Doe 
    

    试着键入hg

    分布式软件配置管理工具 - 水银
    
    基本命令:
    
     add   add the specified files on the next commit
     annotate  show changeset information by line for each file
     clone make a copy of an existing repository
     commitcommit the specified files or all outstanding changes
     diff  diff repository (or selected files)
     exportdump the header and diffs for one or more changesets
     forgetforget the specified files on the next commit
     init  create a new repository in the given directory
     log   show revision history of entire repository or files
     merge merge working directory with another revision
     pull  pull changes from the specified source
     push  push changes to the specified destination
     removeremove the specified files on the next commit
     serve start stand-alone webserver
     statusshow changed files in the working directory
     summary   summarize working directory state
     updateupdate working directory (or switch revisions)
    
    (use "hg help" for the full list of commands or "hg -v" for details)
    

    你还可以通过使用hg help获取完整的命令列表

    建立新仓库

    mkdir project
    cd project
    hg init
    

    现在我们有了全新的仓库

    用hg add添加所有未被最终的文件,或者用hg add 追踪单个文件

    提交更改

    hg commit -m "message"

    或者你也可以用

    hg commit然后在打开的文本编辑器中输入留言

    查看历史

    hg log

    修正错误

    hg revert --all #将所有文件恢复到上次提交时的状态

    hg revert #回复单个文件

    查看修改

    hg status会告诉你这个目录下有什么变化

    ?代表未追踪,M代表已修改,R代表在下一次提交时会被移除,A表示已加入追踪

    查看文件的旧版本

    hg cat #最后一次的提交

    hg cat -r 0 #在版本0时的状态

    对比修改

    hg diff -r 0:1 #在版本0,1间有何改动

    检出历史

    hg update #将目录变为最新状态

    hg update -r 0 #将目录变为版本0时的状态



沪ICP备19023445号-2号
友情链接