GitHub

From Eclipsepedia

Jump to: navigation, search

This page details the required actions to migrating a repo to Eclipse Foundation GitHub.


Contents

Migrating a GitHub repo to Eclipse Foundation GitHub organization

Step 0 - Transfer repo from original location to Eclipse Foundation Organization

  • Make sure IP team has cleared the Initial contribution, and project has TAGged the initial contribution in the repo
  • Transfer the repo

Step 1 - Create new branches and tags with namespace /_old/

Since the Eclipse IP team does not perform a code review on historical code, we must move history to a different namespace. This will allow the Eclipse Foundation to maintain a mirror of the GitHub repository on its servers, without the historical content.

Below, URL implies the SSH url that you can (eventually) push back to.

 $ git clone URL (make a backup)
 $ git --git-dir=new.git init
 $ git --git-dir=new.git fetch URL refs/heads/*:refs/heads/_old/* refs/tags/*:refs/tags/_old/*
 $ git --git-dir=new.git push --all URL
 $ git --git-dir=new.git push --tags URL (if needed)

Replace URL with the repository location on GitHub.

Step 2 - Delete old branches and tags that were renamed

Move your backup clone aside, then re-clone the repo from GitHub.

 # Verify that we are deleting the branches and tags we want to delete
 $ git branch -r | grep -vE "(HEAD|_old|gh-pages)" | cut -d/ -f2 | while read line; do echo :$line; done;
 $ git tag | grep -v "_old" | cut -d/ -f2 | while read line; do echo :$line; done;
 # Actually delete the branches and tags
 $ git branch -r | grep -vE "(HEAD|_old|gh-pages)" | cut -d/ -f2 | while read line; do git push origin :$line; done;
 $ git tag | grep -v "_old" | cut -d/ -f2 | while read line; do git push origin :$line; done;

You'll probably get an error. It is expected.

   remote: error: refusing to delete the current branch: refs/heads/master



Deleting master branch will fail because it's the current branch.

  • NOTE: we should probably not delete branch gh-pages... it's a github special page.... "grep -v gh-pages"?
  • NOTE: should verify that we aren't deleting the new "_old" prefix branches during this process

Step 3 - Push a new Eclipse Approved master

If the project hasn't already squashed history, and master contains an unmodified copy of the initial contribution:

 $ git update-ref -d refs/heads/master
 $ git commit -m "New initial commit"
 $ git push --force origin master


If an initial contribution tag was created(and histroy squashed):

 $ git checkout (TAG)
 $ git branch -d master
 $ git checkout -b master
 $ git push -f origin master

Step 4 - refs replace

Grab refspec for new and old commit

 $ git log
  commit 321465d301a6e2ebabb6945ab260487e89ad42e0     <-- grab this as new_initial_commit
  Author: Denis Roy <denis.roy@eclipse.org>
  Date:   Wed Feb 19 13:27:31 2014 -0500
 $ git log origin/_old/master
   commit 173d1e893ec2921dc02bd8720aca4d25cabdceba     <-- grab this as old_history_last_commit
   Author: (someone)
   Date:   Fri Feb 7 11:53:19 2014 -0500
 $ git replace new_initial_commit old_history_last_commit
 $ git push origin refs/replace/new_initial_commit
  $ git log # should now show all the old history, not just the initial commit
  • NOTE: End user must additionally run (if they want the history): git fetch origin '+refs/replace/*:refs/replace/*'

At this point, clone from the GitHub location just to see if everything is there. But otherwise, the repo is done and historical content is all in _old/.


End User required actions

If a user had previously cloned the repository before it was moved to the Eclipse Foundation GitHub organization, the move will have caused a few issues to the user’s local repository. The easiest option to resolve the issues is to just do a brand new git clone of the repository from the new location. If however this is not an option below outlines issues that the user will run into and steps to resolve the issues.

Fix master branch

The user’s master branch will still be based on the old master branch and needs to be changed to the new master.

The following commands will rename the local master to “old_master” and create a new master based on the new upstream master:

 $ git checkout origin/master
 $ git branch -m master old_master
 $ git checkout -b master

Repeat these steps for any other additional branches that may have conflict.

(Optional) Git Replace history

If the user would like to see the old history attached to the new Initial Commit they can checkout the refs/replace/* refspec.

 $ git fetch origin refs/replace/*:refs/replace/*

Forked repositories

Forked repositories will have branches that no longer match with upstream due to upstream renaming all the branches to /_old/ prefix. The easiest way to resolve this issue is to refork upstream. However if this is not an option below lists the tasks that will need to be considered in each fork of the project.

Fix master branch

The fork’s master branch and upstream master branches will be different. To fix this the fork owner can rename their original master branch and push a new master branch based on the upstream project’s master.

 $ git branch -m master old_master
 $ git push origin old_master
 $ git checkout upstream/master
 $ git checkout -b master
 $ git push --force origin master

WARNING: These command will backup master to old_master and then force pushes a brand new master to your GitHub repository.