hg和git命令对照表

fiy 其他 124

回复

共3条回复 我来回复
  • fiy的头像
    fiy
    Worktile&PingCode市场小伙伴
    评论

    在使用版本控制系统时,开发者通常会选择使用一种命令行工具来执行相关操作。在使用分布式版本控制系统时,最常用的两个工具是Mercurial(hg)和Git。这两个工具都有自己的命令集,但有一些相似的命令可以用于执行相似的操作。

    下面是一个简单的Mercurial(hg)和Git命令对照表:

    1. 初始化一个新的仓库:
    – hg: hg init
    – git: git init

    2. 将文件添加到索引中:
    – hg: hg add [file]
    – git: git add [file]

    3. 提交当前更改:
    – hg: hg commit -m “commit message”
    – git: git commit -m “commit message”

    4. 查看提交历史:
    – hg: hg log
    – git: git log

    5. 查看当前仓库状态:
    – hg: hg status
    – git: git status

    6. 创建一个新的分支:
    – hg: hg branch [branch_name]
    – git: git branch [branch_name]

    7. 切换到一个分支:
    – hg: hg update [branch_name]
    – git: git checkout [branch_name]

    8. 合并分支:
    – hg: hg merge [branch_name]
    – git: git merge [branch_name]

    9. 推送更改到远程仓库:
    – hg: hg push
    – git: git push

    10. 从远程仓库拉取更改:
    – hg: hg pull
    – git: git pull

    11. 克隆一个远程仓库:
    – hg: hg clone [repository_url]
    – git: git clone [repository_url]

    以上是一些常用的Mercurial(hg)和Git命令对照表。虽然两个工具的命令有些差异,但它们的基本功能和操作都是相似的,开发者可以根据自己的喜好和需求选择使用其中之一。

    2年前 0条评论
  • 不及物动词的头像
    不及物动词
    这个人很懒,什么都没有留下~
    评论

    HG命令 Git命令
    hg init git init
    hg clone git clone
    hg add git add
    hg commit git commit
    hg status git status
    hg diff git diff
    hg log git log
    hg pull git pull
    hg push git push
    hg update git checkout
    hg branch git branch
    hg merge git merge
    hg tag git tag
    hg revert git revert
    hg export git format-patch
    hg import git am
    hg out git log origin/master..HEAD
    hg in git log HEAD..origin/master
    hg bookmark git branch -D
    hg rebase git rebase
    hg strip git reset –hard

    另外,需要注意的是,虽然HG和Git都是版本控制工具,但它们的工作方式略有不同。HG使用基于快照的工作流程,而Git则使用基于内容的工作流程。因此,在使用这些命令时,可能会有一些细微的差异。同时,这些命令只是常用命令的对照表,并不包含所有命令和其对应的用法。在具体使用时,请查阅相关文档以获取更详细的信息。

    2年前 0条评论
  • worktile的头像
    worktile
    Worktile官方账号
    评论

    HG和Git是目前非常流行的分布式版本控制系统,它们各自有着一些特定的命令和操作。下面是一个HG和Git命令对照表,以便进行参考:

    1. 创建新仓库:
    HG命令:hg init / hg clone
    Git命令:git init / git clone

    2. 添加文件到仓库:
    HG命令:hg add
    Git命令:git add

    3. 提交更改:
    HG命令:hg commit -m “message”
    Git命令:git commit -m “message”

    4. 查看提交历史:
    HG命令:hg log
    Git命令:git log

    5. 查看文件状态:
    HG命令:hg status
    Git命令:git status

    6. 撤销修改:
    HG命令:hg revert
    Git命令:git checkout —

    7. 分支管理:
    HG命令:hg branch / hg update
    Git命令:git branch / git checkout

    8. 合并分支:
    HG命令:hg merge
    Git命令:git merge

    9. 远程仓库操作:
    HG命令:hg push / hg pull
    Git命令:git push / git pull

    10. 修改最后一次提交:
    HG命令:hg amend
    Git命令:git commit –amend

    11. 看到仓库中文件的变动:
    HG命令:hg diff
    Git命令:git diff

    12. 标签操作:
    HG命令:hg tag
    Git命令:git tag

    13. 远程仓库操作:
    HG命令:hg bookmark / hg push –bookmark
    Git命令:git branch -m / git push origin –delete

    14. 生成补丁:
    HG命令:hg diff -r :-1 > patch.diff
    Git命令:git diff
    > patch.diff

    15. 应用补丁:
    HG命令:hg import patch.diff
    Git命令:git apply patch.diff

    以上是HG和Git一些常用的命令对照表,主要涵盖了仓库创建、文件添加、提交更改、查看历史、分支管理、远程仓库操作、标签操作、生成和应用补丁等操作。不同的命令和操作可能有些差异,但一般来说,对于熟悉其中一种版本控制系统的开发人员来说,学习另一种版本控制系统会相对容易一些。

    2年前 0条评论
注册PingCode 在线客服
站长微信
站长微信
电话联系

400-800-1024

工作日9:30-21:00在线

分享本页
返回顶部