首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Github和Kiln之间的自动同步

Github和Kiln之间的自动同步
EN

Stack Overflow用户
提问于 2011-03-30 16:44:19
回答 4查看 1.4K关注 0票数 9

我是一个前端设计师,没有大量的编程背景。我做CSS/html和一些JavaScript。我们公司的技术团队已经将我们的版本控制从Git (github)转移到Mercurial (Kiln)。它们的唯一原因是为了获得Kiln的代码审查功能(我们使用Fogbugz并喜欢它)。

问题是,在我们的版本控制中工作的前端和非开发人员一直在工作。我们使用hg-git在Heroku上部署,并使用git (从未与其他版本控制系统一起工作过)。我确信Mercurial是一个很棒的工具,但我必须得出结论,我们在问题和错误上花费了太多的时间。

我的想法是:有没有一种方法可以在github上使用git,然后将所有提交等同步到Mercurial (Kiln)?然后,我们可以使用git,并且仍然拥有Kiln的代码审查功能。

希望你能帮上忙。我很乐意带着解决方案回到我们的技术团队;)

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2011-03-30 22:05:16

与学习Mercurial相比,您设置的任何同步都更容易出错。Git和Mercurial都是很棒的工具,而且非常相似,所以如果你不是逐个任务地去做,而是花一个小时来了解它们的不同之处,你就可以毫无问题地来回切换。

不太好的同步选项有: git-hg、hgit和Mercurial的convert扩展,以及Mercurial对Git子存储库的支持,但您会对其中任何一个感到遗憾,因为与单独使用这两个工具相比,它们都需要对有更好的理解。

要么让开发人员切换回来,要么让他们为你重写你的部署内容,但不要费心在同一个公司内部。

票数 8
EN

Stack Overflow用户

发布于 2013-03-13 03:32:41

今天Kiln v3发布了Kiln Harmony,它有原生的Git支持(事实上,它允许Mercurial和Git在同一个repos上!)。

作为Mercurial的粉丝,我写了一个脚本来定期与GitHub同步Kiln Repo,这样我就可以在GitHub上托管我的代码,但仍然每天只使用Mercurial。

最新版本的the PowerShell function is available as a Gist,但为了方便起见,我也在这里粘贴了当前版本。

代码语言:javascript
复制
<#
.SYNOPSIS
    Script to sync a GitHub repo to Kiln to allw GitHub contributions without using Git (use Hg on your Kiln repos!).
.DESCRIPTION
    Create a branch repo in Kiln specifically for for the GitHub sync and run this PS script periodically (PoSh v3
    scheduled jobs make this easy).

    Merge the GitHub branch repo (using Hg!) into your main repo periodically, then push back to the GitHub branch
    once done. This will be sync'd back to GitHub when the script next runs.

    Avoid simultaneous changes in the GitHub repo and the Kiln GitHub branch repo, as we don't want the automated
    script merging (esp. as they could conflict).
.EXAMPLE
    Sync-GitRepositories `
        "$kilnBase/Misc/Group/NewSyncTest-GitHub.git" `
        "$githubBase/NewSyncTest.git" `
        "$tempSyncBase\Scripted"
#>
function Sync-GitRepositories
{
    param(
        [Parameter(Mandatory)]
        [string]$gitRepo1,
        [Parameter(Mandatory)]
        [string]$gitRepo2,
        [Parameter(Mandatory)]
        [string]$tempSyncPath,
        [string]$gitExecutable
    )

    # If we weren't given a path to git, assume it's in the path.
    if (!$gitExecutable)
        { $gitExecutable = "git" }

    # Clone the Kiln Github branch repo if we haven't already got a copy.
    if (!(Test-Path $tempSyncPath))
    {
        & $gitExecutable clone $gitRepo1 $tempSyncPath | Out-Default
        Push-Location $tempSyncPath

        # Add a remote for the GitHub repo that we're syncing with.
        & $gitExecutable remote add github $gitRepo2 | Out-Default
    }
    else
    {
        Push-Location $tempSyncPath
    }

    # Fetch changes from the Kiln GitHub branch repo and merge them in.
    # Note: Use FastForward-Only to avoid merging (this is automated!), if changes are made to
    # both GitHub and Kiln GitHub branch simultaneously, we'll have to manually resolve it.
    # Errors from this script should be emailed to the user!
    # Note: Always use -q because Git writes progress to STDERR! #WTF
    & $gitExecutable fetch origin -q | Out-Default
    & $gitExecutable merge origin/master --ff-only -q | Out-Default

    # Repeat the process with any changes from GitHub.
    & $gitExecutable fetch github -q | Out-Default
    & $gitExecutable merge github/master --ff-only -q | Out-Default

    # Push changes back to both Kiln GitHub branch repo and GitHub repo.
    & $gitExecutable push origin : -q | Out-Default
    & $gitExecutable push github : -q | Out-Default

    Pop-Location
}
票数 3
EN

Stack Overflow用户

发布于 2011-03-30 17:15:24

也许您可以使用git post-commit挂钩通过git-hg将您的更改推送/同步到Kiln

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5484017

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档