1

I will be having two git repositories:

  1. Github

  2. OpenShift

Both are going to have the same content. I just have to make sure they are in sync.

I currently have my origin renamed to github so that by doing git push github master, I push to github and for openshift I am planning to have a remote openshift that points to openshift git repository.

This way I can push codes separately:

  • git push github master
  • git push openshift master

Currently after running git remote -v I get:

$ git remote -v
github  https://github.com/animesh/asdf.git (fetch)
github  https://github.com/animesh/asdf.git (push)
github  ssh://xxxxx@asdf-animesh.rhcloud.com/~/git/asdf.git (push)

I added an upstream path to the openshift repo so that as soon as I push in github, the content is also pushed into openshift repo but I am finding it hard to manage.

How can I maintain two remotes in the way I want to?

Animesh Pandey
  • 5,900
  • 13
  • 64
  • 130

2 Answers2

0

As far as I understood you added two push URLs to your remote but you want to have two remotes to which you can and have to push individually.

So what I'd recommend is, rename your github remote to both and then use git remote add to add a github remote and again to add an openshift remote. This way you can push to one remote or to both remotes with one command, depending on which remote you push to.

Vampire
  • 35,631
  • 4
  • 76
  • 102
0

You can use a git hook to automatically push to the remote openshift if the push to github is OK. The post-update hook is a script which runs after the push command. It seems to be what you are looking for.

Edit : I saw Vikram Tiwari comment and he is right, the link Manage multiple remote seems a better / easier solution.

Community
  • 1
  • 1
Flows
  • 3,675
  • 3
  • 28
  • 52