the Hg-Git mercurial plugin

This is the Hg-Git plugin for Mercurial, adding the ability to push to and pull from a Git server repository from Mercurial. This means you can collaborate on Git based projects from Mercurial, or use a Git server as a collaboration point for a team with developers using both Git and Mercurial.

The Big Idea

The Hg-Git plugin can convert commits/changesets losslessly from one system to another, so you can push via a Mercurial repository and another Mercurial client can pull it. In theory, the changeset IDs should not change, although this may not hold true for complex histories.

Commands

You can clone a Git repository from Mercurial by running hg clone [url]. It will create a directory with the same name as the last path component. For example, if you were to run hg clone git://github.com/schacon/munger.git it would clone the repository down into the directory 'munger.git', then convert it to a Mercurial repository for you.

hg clone git://github.com/schacon/munger.git

If you are starting from an existing Mercurial repository, you have to setup a Git repository somewhere that you have push access to, and then run hg push [path] from within your project. For example:

$ cd hg-git # (a Mercurial repository)
$ hg bookmark -r default master # make a bookmark of master for default, so a ref gets created
$ hg push git+ssh://git@github.com/schacon/hg-git.git
$ hg push

This will convert all our Mercurial data into Git objects and push them up to the Git server. You can also put that path in the [paths] section of .hg/hgrc and then push to it by name.

Now that you have a Mercurial repository that can push/pull to/from a Git repository, you can get updates with hg pull.

$ hg pull

That will pull down any commits that have been pushed to the server in the meantime and give you a new head that you can merge in.

Installing

The easy way:

Run easy_install hg-git, then add make sure the following is in your ~/.hgrc:

[extensions]
hgext.bookmarks =
hggit = 

...and that's it! Note that this requires having working C compilers on your system.

The more involved way

First, install version 0.8.0 or newer of dulwich. You can do easy_install 'dulwich>=0.8.0' if you have setuptools installed. Clone this repository somewhere, then make the 'extensions' section in your '~/.hgrc' file look something like this:

[extensions]
hgext.bookmarks =
hggit = [path-to]/hg-git/hggit

That will enable the Hg-Git extension for you. The bookmarks section is only required prior to hg 1.7. Bookmarks will be translated to git heads when pushing.

Dependencies

This plugin is implemented entirely in Python - there are no Git binary dependencies, you do not need to have Git installed on your system. There are in fact no external dependencies currently other than Mercurial and Dulwich. The plugin is known to work on Mercurial 1.7, and is basically functional (with a couple of bugs) against hg 1.8 and 1.9.

Note that Dulwich has C extensions, so it requires a C compiler when installing via easy_install. On Windows, one option is the free Microsoft Visual C++. Be sure to install the 2008 version for compatibility reasons. On debian-style linux, run: apt-get install python-dev.

Sources

Source available via hg (canonical repo) or git (mirror of hg). Patches preferred via email to the hg-git mailing list.

This plugin was originally developed by the folks at GitHub, and is currently maintained by Augie Fackler.
::...
免责声明:
当前网页内容, 由 大妈 ZoomQuiet 使用工具: ScrapBook :: Firefox Extension 人工从互联网中收集并分享;
内容版权归原作者所有;
本人对内容的有效性/合法性不承担任何强制性责任.
若有不妥, 欢迎评注提醒:

或是邮件反馈可也:
askdama[AT]googlegroups.com


订阅 substack 体验古早写作:


点击注册~> 获得 100$ 体验券: DigitalOcean Referral Badge

关注公众号, 持续获得相关各种嗯哼:
zoomquiet


自怼圈/年度番新

DU22.4
关于 ~ DebugUself with DAMA ;-)
粤ICP备18025058号-1
公安备案号: 44049002000656 ...::