using git but pushing to mercurial?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 07:42:30
Lazy Badger

Think some time, see alternative solution, same lopsided and crooked, but less pretentious (I hope) - 3 repos (2 Mercurial + 1 Git) in 3-tier architecture of chain

They have (local) names, used below:

  • Master (hg) - central Mercurial repo of company
  • Mediator (hg) - middleware for translating changesets, created as clone of Master
  • WorkHorse (git) - final workplace, empty at start

Mediator have setting almost identical (hg-git, bookmarks) to hg-repo from solution 1, except one detail in [paths] section of hgrc - will be two path in in: Master and WorkHorse in order to be able pull|push in both direction, with Master and WorkHorse

Workflow:

  • Mediator pull changes from Master, push to WorkHorse (changesets presented as is, without collapsing, contrary to solution 1)
  • All (almost? not sure about merges) work happens on WorkHorse
  • Mediator pull changes from WorkHorse, push to Master
Lazy Badger

You can work with Mercurial end-point from git, but, unlike the inverse direction (hg -> git) you'll have to have both VCS and two repos on same location

  1. Install Mercurial
  2. Install hg-git extension for Mercurial
  3. Make sure you've enabled the Hg bookmark extension in your .hgrc
  4. Add to your .hgrc:

    [git]
    intree=1
    
  5. Clone your Mercurial repo

    hg clone ... repo
    
  6. Go to repo

    cd repo
    
  7. Create a local bookmark tracking your Mercurial default branch - this is what will be exported to your Git

    hg bookmark hg/default -r default
    
  8. Export to the git repo

    hg gexport
    
  9. Configure Hg to ignore the Git repo

    echo ".git" >> .hg/hgignore
    
  10. Configure Git to ignore the Hg repo

    echo ".hg*" >> .git/info/exclude
    
  11. Configure Git to ignore the same things as Mercurial

    git config core.excludesfile `pwd`/.hg/hgignore
    
  12. Have your master branch track the exported Hg default branch

    git branch --track master hg/default
    git reset --hard
    
  13. Work and commit to Git as usual

  14. Export your changes to Hg

    hg gimport
    
  15. Push all to the world

    hg push
    

For every-day-work repeat steps 13-15

PS: Work from HG to Git produces a lot less actions and headache

Nowadays, there is a new git-remote-hg extension that does what you need. It seems to be the counterpart to Hg-Git plugin. See http://felipec.wordpress.com/2012/11/13/git-remote-hg-bzr-2/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!