Best way to solve mirroring a remote in Stash?

We recently completed a migration from an old gitosis/gitweb/git daemon server to Stash; a handful of repositories had been "fiddled with" on the server, it turns out. The .git/config file was modified and some remotes were added - say, a remote called "upstream" with the url to an open source project out on the interwebs. Then a cron job had been installed to go into the folder on the git server and do a git fetch & prune. The end result is the hosted repos magically stayed up to date on specific "branches" with the open source community. I didn't know about this until the final few days of the move from gitosis to Stash. So not addressing the pro's and con's of whether or not this is wise - that's a seperate question - what's the best way to solve this in Stash?

I would rather not dig into the Stash data folder and manually edit the .git/config file in the handful of repos and run a cron job to do a behind the scenes fetch, mostly because I'm not confident it would work, and I'm also worried about messing around where I shouldn't - Stash's documentation clearly states to not manually modify anything in your data folder. I would like to keep upgrading Stash without a problem, so I don't want to cause a headache for myself down the road. I've checked out the marketplace as well - the two mirroring plugins that are up to date mirror the wrong direction - they allow you to mirror your Stash repo to somewhere else - either another instance of Stash, or another git server completely (bitbucket, github, et al). There's one plugin that looks like it might have worked but it quit being updated after Stash 2.2 and doesn't look viable any longer.

One idea I have is to use Bamboo for this, instead of cron. Make a sh script task to clone the open source repo and push it to our Stash repo. Like this - here’s the old .git config:

[remote "upstream"]

url = git://git.yoctoproject.org/yocto-autobuilder.git

fetch = +refs/heads/*:refs/heads/upstream/*

Here’s my solution:

git clone git://git.yoctoproject.org/yocto-autobuilder.git

cd yocto-autobuilder

git push --prune ssh://git@our-stash.server.com:7999/test/yocto-autobuilder.git +refs/remotes/origin/*:refs/heads/upstream/* +refs/tags/*:refs/tags/*

This seems to work, but I'm not sure if this will work day after day. I'm obviously not a git guru either, so I'm not even sure if this is canon or correct. What do you all think? How would you solve this (in the technical sense - again, please don't address how "smart" this is).
-Kelly Schoenhofen

1 answer

1 accepted

0 vote
Roger Barnes Atlassian Team Oct 02, 2013

Hi Kelly,

You're right to avoid digging into Stash's data folder for this. The general solution would be to externally poll and push via git, so your approach of using a bamboo task to push updates to Stash is a good one. I'm not sure of the exact syntax for the push command to use, there might be something simpler or more reliable.

Thanks. I also hit the Expert Bar at Summit13 and they said essentially the same thing. They hemmed and hawwed ;) a little on whether or not to stay out of the data fold; they said in this instance it wouldn't be the end of the world, but they generally agreed to stay out of it, unless the alternative is worst than going into data.

They liked the bamboo git clone & git push method best, with modifying the .git configs in the data folder & a cron job a distant second. I'll mark your response as the answer, thanks!

-Kelly

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

27,069 views 26 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you