Differences between revisions 1 and 15 (spanning 14 versions)
Revision 1 as of 2009-07-22 19:19:27
Size: 3234
Comment:
Revision 15 as of 2020-01-08 22:38:36
Size: 4412
Editor: muxator
Comment: Removed reference to "bookmarks" extension, that is in core since 2011 (https://www.mercurial-scm.org/repo/hg/rev/d4ab9486e514)
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
Line 5: Line 4:
''Author: Scott Chacon, Augie Fackler and Abderrahim Kitouni'' ''Author: Scott Chacon, Augie Fackler, Abderrahim Kitouni, and Sverre Rabbelier''
Line 7: Line 6:
Download site: http://bitbucket.org/abderrahim/hg-git Web page: https://hg-git.github.io/

Mailing list: https://groups.google.com/group/hg-git

Repository: https://dev.heptapod.net/mercurial/hg-git
Line 10: Line 13:
This extension adds the ability to work on a Git repository from Mercurial. It also allows using a Git server as a collaboration point for a team with developers using both Git and Mercurial. This extension adds the ability to work on a Git repository from Mercurial. It also allows using a Git server as a collaboration point for a team with developers using both Git and Mercurial. At the same time, it can also be used to interact with a hg repository using git.
Line 15: Line 18:
You can clone a Git repository as you would clone a mercurial repository, for example :
Line 16: Line 20:
You can clone a Git repository as you would clone a mercurial repository, for example :
Line 25: Line 28:
Line 33: Line 37:
Line 37: Line 42:
The bookmarks extension is not necessary, one can work using solely local tags, but it's more convenient to use it. === Using hg-git to interact with a hg repository with git ===
''TODO: this section is outdated (references to master branch and exportbranch config)''

You can create a local .git repository like this:

Editr the .hg/hgrc (or your ~/.hgrc if you want to make this the default):

{{{
[git]
intree=1
}}}
Then do the following from in the hg repository:

{{{
hg gexport
}}}
This will create a .git repository in the working directory (alongside the .hg directory) that you can interact with like any regular git repository. If you have made commits in the git repository and want to convert them to hg commits, first make sure the changes you want are on the master branch, then do:

{{{
hg gimport
}}}
This will put your changes on top of the current hg tip.

Optionally you can change your hgrc to include an exportbranch statement:

{{{
[git]
intree=1
exportbranch=refs/heads/from-hg
}}}
This will cause 'hg gexport' to update the 'from-hg' branch, instead of the master branch, so that your changes will not be lost even if you work on the master branch.
Line 40: Line 75:
''TODO: this section is outdated''
Line 41: Line 77:
If you want to help with the developpement of hg-git, here are some things you can help with : If you want to help with the development of hg-git, here are some things you can help with :
Line 48: Line 85:
This plugin is implemented entirely in Python - there are no Git binary dependencies, you do not need to have Git installed on your system. The only dependencies are Dulwich (there is currently a modified version in the repo, but it'll be soon removed) and Mercurial (it should work with Mercurial versions 1.1-1.3). This plugin is implemented entirely in Python - there are no Git binary dependencies, you do not need to have Git installed on your system. The only dependencies are [[http://samba.org/~jelmer/dulwich/|Dulwich]] 0.4.1 or later and Mercurial (it should work with Mercurial versions 1.1-1.3).
Line 55: Line 92:
hgext.bookmarks = 
git = /path/to/hg-git
hgext.bookmarks =
hggit = /path/to/hg-git
Line 58: Line 95:

hg-git Extension

This extension is not distributed with Mercurial.

Author: Scott Chacon, Augie Fackler, Abderrahim Kitouni, and Sverre Rabbelier

Web page: https://hg-git.github.io/

Mailing list: https://groups.google.com/group/hg-git

Repository: https://dev.heptapod.net/mercurial/hg-git

Overview

This extension adds the ability to work on a Git repository from Mercurial. It also allows using a Git server as a collaboration point for a team with developers using both Git and Mercurial. At the same time, it can also be used to interact with a hg repository using git.

It can convert commits/changesets losslessly from one system to another, so you can push from a Mercurial repository and another Mercurial client can pull it and their changeset node ids will be identical - Mercurial data does not get lost in translation. It is intended that Mercurial users may wish to use this to collaborate even if no Git users are involved in the project, and it may even provide some advantages if you're using Bookmarks (see below).

Commands

You can clone a Git repository as you would clone a mercurial repository, for example :

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

will clone the git mirror of the hg-git repository in a directory named 'hg-git.git'.

TODO: document the difference between ssh://host/path and host:path git urls and how they map to hg.

If you want to clone a repository via ssh, you can do so using a git+ssh:// protocol prefix :

hg clone git+ssh://git@github.com/schacon/hg-git.git

This will also create a bookmark for each git branch, and add local tags default/<branch name> for each branch. This is similar to origin/<branch name> in git.

When you pull from a git repository in the [paths] section of hgrc, it will "fast-forward" the bookmarks if the branches haven't diverged. It will also create local tags as above.

When pushing to git, the following is done to determine what's pushed :

  • if there are no bookmarks and the remote repository is empty, the tip is pushed as the master branch.
  • for each branch in the remote repository, if there is a bookmark or a tag with the same name that points to a descendent of the head, then push it.
  • if there are bookmarks with no remote branch, a new branch is created.

Using hg-git to interact with a hg repository with git

TODO: this section is outdated (references to master branch and exportbranch config)

You can create a local .git repository like this:

Editr the .hg/hgrc (or your ~/.hgrc if you want to make this the default):

[git]
intree=1

Then do the following from in the hg repository:

hg gexport

This will create a .git repository in the working directory (alongside the .hg directory) that you can interact with like any regular git repository. If you have made commits in the git repository and want to convert them to hg commits, first make sure the changes you want are on the master branch, then do:

hg gimport

This will put your changes on top of the current hg tip.

Optionally you can change your hgrc to include an exportbranch statement:

[git]
intree=1
exportbranch=refs/heads/from-hg

This will cause 'hg gexport' to update the 'from-hg' branch, instead of the master branch, so that your changes will not be lost even if you work on the master branch.

TODO

TODO: this section is outdated

If you want to help with the development of hg-git, here are some things you can help with :

  • push/pull -r
  • incoming/outgoing
  • better handling for tags (see this thread on the mailing list).

  • make pushing using dulwich more efficient (faster packing, thin packs, etc).

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. The only dependencies are Dulwich 0.4.1 or later and Mercurial (it should work with Mercurial versions 1.1-1.3).

Configuration

Configure your .hgrc to enable the extension by adding following lines:

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


CategoryExtensionsByOthers

HgGit (last edited 2021-03-02 16:45:54 by DanVilliomPodlaskiChristiansen)