fourg
fourg

Reputation: 13

How do I copy a GitHub.com repository to a private Git server?

I'm new to git and trying to figure out the best way to copy an existing GitHub.com repository owned by another user to a private git server I have on Atlassian Stash. Ideally we could do a copy at least once a month.

The tedious method I'm doing right now is cloning the GitHub.com repository to a private workstation and then adding a remote to an empty repository in Atlassian Stash and pushing it. This isn't a big deal for one repository, but we have at least a couple dozen we'd like to copy.

From what I've understood I as an owner can setup remotes for a repository to push changes to multiple locations, but I haven't figured out how as a non-owner to pull a repository. There are two plugins available in the Atlassian community and both seem to only offer pushing of repositories to remotes, and not pulling as I need.

Upvotes: 1

Views: 216

Answers (1)

GoZoner
GoZoner

Reputation: 70225

If you are creating empty repositories under 'Atlassian Stash' and pushing into them the GitHub.com local clone that you made, then what could developers be using a new repository for every month or so? Sounds like the overall development process isn't working...

Have a single central repository that your developers clone from and deliver their work to. In that central repository have a branch that tracks one or more branches at the remote, GitHub.com repository. You update those remote branches as often as you want by simply using git pull. Then, every so often, so as not to upset the work of everybody on your team, you carefully merge the remotes into your development branch. Then you team pulls the updated development branch and continues working.

[EDIT]

The process that you are following (cloning GitHub, pushing to an empty Atlassian Stash repository) appears to be exactly as described in Atlassian Documentation for 'Importing Code from an Existing Project'.

I think you have a couple of options:

  1. Since you need to clone GitHub anyway, have the clone serve as the archive - that is skip Stash altogether. Each month you'll end up with a new repository for each project.
  2. Git repositories keep detailed change history (which is the point of a software CM system) so you don't need multiple archives, every month, just pull each month and add your own tag. This won't work if you suspect that original repo owner is making destructive changes.
  3. Setup a cron script.

Upvotes: 1

Related Questions