Created
November 30, 2012 05:57
-
-
Save youpy/4173999 to your computer and use it in GitHub Desktop.
consolidate two git repos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding: utf-8; ruby -*- | |
# http://d.hatena.ne.jp/okinaka/20111010/1318211550 | |
require 'shellwords' | |
def main | |
old = File.expand_path(ARGV[0]) | |
new = File.expand_path(ARGV[1]) | |
branch_name = Time.now.to_i.to_s | |
Dir.chdir(old) do | |
git('fetch %s refs/heads/master:refs/heads/%s' % [Shellwords.escape(new), branch_name]) | |
git('checkout %s' % branch_name) | |
git('rebase master') | |
git('checkout master') | |
git('merge %s' % branch_name) | |
git('branch -d %s' % branch_name) | |
end | |
end | |
def git(cmd) | |
cmd = 'git ' + cmd | |
puts cmd | |
system cmd | |
end | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment