Looking for a JavaEE Architect or Potential Tech Co-Founder?
Please don't hesitate to contact me.

How to sync github and openshift git repository

OpenShift is such a wonderful playground for those who want to try and experience real javaee6/jboss cloud hosting. But often some of us wanted to host the code in another git repository like github or bitbucket or somewhere else. This article will try to explain how we can synchronize between 1 git repository to another.

Before we begin you should have:
1.) Eclipse with maven plugin and egit plugin.
2.) An account in OpenShift with JBoss7 application, some instructions can be found here:

The following steps will clone a repository from OpenShift and add a GitHub repository to it. So you can merge them.

1.) Clone your OpenShift repository. Open Git Repository view and click Clone a Git repository.

2.) Select the master branch, and enter parameters like where you want to save the repository, etc.

3.) Next you have to add Github to the Remotes repository section of the newly cloned one. But unfortunately, it's not working with eclipse egit plugin. So we have to execute in cmd.
  a.) Navigate to where you save the cloned OpenShift repository.
  b.) Execute: git remote add github -f https://github.com/czetsuya/crudfaces.git
       This will add my github remote repository to openshift clone.

4.) After adding the github repo, your Git Repositories view should look like:

*Notice that github, is added in the Remotes section.

5.) Since we wanted to merge openshift into github, first we need to checkout the github master branch.
  a.) In Branches->Remote Tracking menu, right click on github/master and then select Create a branch, enter github-master. Pull Strategy=None.

6.) And finally to merge OpenShift into Github, right click on Branches->Local->github-master, and select merge. Choose Remote Tracking->origin/master, which is the OpenShift master branch.

7.) You can now import the maven projects by, right click on repository and select Import Maven Projects.

Now you have a repository connected to OpenShit and at the same time can push to GitHub.
How to sync github and openshift git repository How to sync github and openshift git repository Reviewed by Edward Legaspi on Tuesday, June 18, 2013 Rating: 5

No comments:

Powered by Blogger.