cypheratheist cypheratheist - 2 months ago 17
Git Question

Maintaining a clone of a git repository

I want to make a clone of a github repostitory in a (self-hosted) bitbucket server and from time to time pull the latest changes from the github repository. In our clone we're going to do some experimental stuff which will never leave our repository.

To illustrate; with fossil I'd make sure that our repository and their repository has the same project id, and I'd do this:

$ cd ~/checkout/prjdir
$ fossil pull --once

This would get all the latest checkins, branches, tags, etc. And then to push it to our organization's server:

$ fossil push

There will never be any conflicts; our changes will be made on experimental branches so there's no need for any merges when updating from upstream.

I've tried to replicate the fossil workflow and copy/pasted some things which seem relevant and come up with this for the initial cloning:

$ git clone
$ cd bar
$ git remote set-url origin
$ git push -u origin master

This however doesn't appear to have brought with it the tags (tags are important to us).

With git (github as upstream and our bitbucket server for our own tags/branches):

  1. how do I make a complete clone of a repository (including all
    branches and tags)?

  2. once I have a cloned repository, how do I
    pull all the latest changes (branches, tags included) from upstream
    (on github) and push them to our server (bitbucket)?


Don't change the URL of the repository. Just create two remotes, upstream and origin.

Tags aren't pushed by default. Use --tags to push them.

$ git clone
$ cd bar
$ git remote rename origin upstream
$ git remote add origin
$ git push -u --tags origin master

Whenever you want to synchronize with the upstream, do

$ git checkout master
$ git pull upstream master

or even

$ git reset --hard upstream/master

and rebase your branch (or merge master into it) to incorporate their changes into your work:

$ git checkout my-branch
$ git rebase master


$ git checkout my-branch
$ git merge master