Skip to content

Instantly share code, notes, and snippets.

@dlangille
Last active September 12, 2016 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlangille/912abc35abf3d42594839d1ddb10bdc6 to your computer and use it in GitHub Desktop.
Save dlangille/912abc35abf3d42594839d1ddb10bdc6 to your computer and use it in GitHub Desktop.
pull from one repo, push to github... sort of like a private / public setup.
as found at http://stackoverflow.com/questions/6150188/how-to-update-a-git-clone-mirror
$ git remote update origin
Fetching origin
remote: Counting objects: 2, done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 2 (delta 1), reused 2 (delta 1), pack-reused 0
Unpacking objects: 100% (2/2), done.
From git.vrt.sourcefire.com:dvl/TestForPushing
ef2b7d5..a5164a3 master -> master
$ git push --mirror push_mirror
Counting objects: 2, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 219 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local objects.
To git@github.com:dlangille/TestForPushing
ef2b7d5..a5164a3 master -> master
$ git pull origin
fatal: /usr/local/libexec/git-core/git-pull cannot be used without a working tree.
$ git pull --mirror origin
fatal: /usr/local/libexec/git-core/git-pull cannot be used without a working tree.
$ git pull --mirror origin master:master
fatal: /usr/local/libexec/git-core/git-pull cannot be used without a working tree.
$ git pull origin master
fatal: /usr/local/libexec/git-core/git-pull cannot be used without a working tree.
$ git remote
origin
push_mirror
git remote show origin
* remote origin
Fetch URL: git@git.example.com:dvl/TestForPushing.git
Push URL: git@git.example.com:dvl/TestForPushing.git
HEAD branch: master
Remote branches:
master tracked
refs/remotes/push_mirror/master stale (use 'git remote prune' to remove)
Local refs will be mirrored by 'git push'
$ git remote show push_mirror
* remote push_mirror
Fetch URL: git@github.com:dlangille/TestForPushing
Push URL: git@github.com:dlangille/TestForPushing
HEAD branch: master
Remote branch:
master tracked
Local ref configured for 'git push':
master pushes to master (up to date)
# pull and mirror the repo
$ git clone --mirror git@git.example.com:dvl/TestForPushing.git
# this is where I want to push
$ git remote add push_mirror git@github.com:dlangille/TestForPushing
# I manually created a mirror on github via the website...
# push mirror the repo I have...
$ git push --mirror git@github.com:dlangille/TestForPushing
This worked just fine, as seen at https://github.com/dlangille/TestForPushing
But a pull fails:
$ git pull
fatal: /usr/local/libexec/git-core/git-pull cannot be used without a working tree.
Pushing is just fine:
$ git push --mirror push_mirror
Total 0 (delta 0), reused 0 (delta 0)
To git@github.com:dlangille/TestForPushing
* [new branch] push_mirror/master -> push_mirror/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment