I am a frontend designer and don't have a large programming background. I do CSS/html and a bit of JavaScript. The tech team at our company has moved our version control from Git (github) to Mercurial (Kiln). The only reason for them is to get the code review feature of Kiln (we use Fogbugz and love it).
The problem is that the frontenders and non-developers working in our version control are funcking up all the time. We use hg-git to deploy on Heroku and are used to git (never worked with other version control systems). I am sure that Mercurial is a great tool, but I must conclude that we spend too much time on problems and errors.
My thought was: Is there a way to use git on github and then sync all the commits etc to Mercurial (Kiln)? Then we would get to use git and still have the code review features of Kiln.
Hope you can help. I would love to come back to our tech team with a solution ;)
Any synchronization you set up is going to be more error prone than just learning Mercurial. Git and Mercurial are both great tools, and very similar, so if rather than going at it piecemeal task-by-task you spend a good hour reading about the differences you'll be able to switch back and forth without any problem.
Not-great options for synchronization are: git-hg, hgit, and Mercurial's convert extension, and Mercurial's support for git subrepositories, but you'll regret any of them because they'll require a greater understanding of both tools than using either of them alone would.
Either make the developers switch back or make them rewrite your deploy stuff for you, but don't bother straddling within the same company.
Today Kiln v3 was launched with Kiln Harmony which has native Git support (in fact, it allows both Mercurial and Git on the same repos!).
As a fan of Mercurial, I wrote a script to sync a Kiln Repo periodically with GitHub so I can host my code on GitHub but still use only Mercurial on a daily basis.
The latest version of the PowerShell function is available as a Gist, but I've pasted the current version here for convenience too.
<#
.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
}
Perhaps you could use a git post-commit hook to push/sync your changes to Kiln using git-hg?
You could also set up a Custom Web Hook in Kiln to synchronize to Git from Kiln.
来源:https://stackoverflow.com/questions/5484017/automated-sync-between-github-and-kiln