[github] bitbucket에서 github로 모든 분기가있는 git 저장소를 이동하는 방법은 무엇입니까?

모든 분기와 전체 히스토리가있는 git 저장소를 bitbucket에서 github로 옮기는 가장 좋은 방법은 무엇입니까? 사용해야하는 스크립트 나 명령 목록이 있습니까?



답변

당신은 GitHub의 페이지 “를 참조 할 수 있습니다 저장소를 복제

다음을 사용합니다.

그것은 줄 것이다 :

git clone --mirror https://bitbucket.org/exampleuser/repository-to-mirror.git
# Make a bare mirrored clone of the repository

cd repository-to-mirror.git
git remote set-url --push origin https://github.com/exampleuser/mirrored
# Set the push location to your mirror

git push --mirror

언급 한 바와 같이 주석에 의해이야 LS :


답변

매우 간단합니다.

GitHub에서 빈 저장소를 새로 만듭니다 (readme 또는 licesne없이 이전에 추가 할 수 있음). 다음 화면이 표시됩니다.

내부에서 코드 옵션 을 가져 오기 위해 비트 버킷 URL의 저장소와 모음을 붙여 넣습니다!

가져 오기 코드를 클릭하십시오


답변

github에서 “코드 가져 오기”버튼을 찾을 수없는 경우 다음을 수행 할 수 있습니다.

  1. Github Importer를 직접 열고을 입력하십시오 url. 다음과 같이 보일 것입니다 :github importer의 스크린 샷
  2. 이름을 지정하십시오 (또는 이름을 자동으로 가져옵니다).
  3. 선택 Public또는 Private저장소
  4. 딸깍 하는 소리 Begin Import

업데이트 :
최근 Github에서는 “할 수있는 기능 발표 큰 파일 가져 오기 저장소를


답변

http://www.blackdogfoundry.com/blog/moving-repository-from-bitbucket-to-github/

이것은 하나의 자식 공급자에서 다른 공급자로 이동하는 데 도움이되었습니다. 그 끝에서 모든 커밋은 대상 git에있었습니다. 간단하고 똑바로.

git remote rename origin bitbucket
git remote add origin https://github.com/edwardaux/Pipelines.git
git push origin master

푸시가 GitHub에 성공적으로 적용되었다는 사실에 만족하면 다음을 실행하여 기존 리모컨을 삭제할 수 있습니다.

git remote rm bitbucket

답변

기존 저장소를 github에서 bitbucket으로 가져 오는 역 유스 케이스가있었습니다.

Bitbucket은 가져 오기 도구 도 제공합니다. 유일하게 필요한 단계는 리포지토리에 URL을 추가하는 것입니다.

다음과 같습니다.

비트 버킷 가져 오기 도구의 스크린 샷


답변

나는 이것이 오래된 질문이라는 것을 알고 있습니다. 몇 달 전에 내가 똑같은 일을하려고 할 때 그것을 발견했으며 주어진 대답에 압도되었습니다. 그들은 모두 단품으로 발행 된 명령이나 GitHub 임포터를 통해 Bitbucket에서 GitHub로 한 번에 하나의 저장소를 가져 오는 것을 처리하는 것처럼 보였습니다.

gitter라는 GitHub 프로젝트에서 코드를 가져 와서 내 요구에 맞게 수정했습니다.

요점을 포크 하거나 여기에서 코드를 가져올 수 있습니다.

#!/usr/bin/env ruby
require 'fileutils'

# Originally  -- Dave Deriso        -- deriso@gmail.com
# Contributor -- G. Richard Bellamy -- rbellamy@terradatum.com
# If you contribute, put your name here!
# To get your team ID:
# 1. Go to your GitHub profile, select 'Personal Access Tokens', and create an Access token
# 2. curl -H "Authorization: token <very-long-access-token>" https://api.github.com/orgs/<org-name>/teams
# 3. Find the team name, and grabulate the Team ID
# 4. PROFIT!

#----------------------------------------------------------------------
#your particulars
@access_token = ''
@team_id = ''
@org = ''


#----------------------------------------------------------------------
#the verison of this app
@version = "0.2"

#----------------------------------------------------------------------
#some global params
@create = false
@add = false
@migrate = false
@debug = false
@done = false
@error = false

#----------------------------------------------------------------------
#fancy schmancy color scheme

class String; def c(cc); "\e[#{cc}m#{self}\e[0m" end end
#200.to_i.times{ |i| print i.to_s.c(i) + " " }; puts
@sep = "-".c(90)*95
@sep_pref = ".".c(90)*95
@sep_thick = "+".c(90)*95

#----------------------------------------------------------------------
# greetings

def hello
  puts @sep
  puts "BitBucket to GitHub migrator -- v.#{@version}".c(95)
  #puts @sep_thick
end

def goodbye
  puts @sep
  puts "done!".c(95)
  puts @sep
  exit
end

def puts_title(text)
   puts  @sep, "#{text}".c(36), @sep
end

#----------------------------------------------------------------------
# helper methods

def get_options
  require 'optparse'

  n_options = 0
  show_options = false

  OptionParser.new do |opts|
    opts.banner = @sep +"\nUsage: gitter [options]\n".c(36)
    opts.version = @version
    opts.on('-n', '--name [name]', String, 'Set the name of the new repo') { |value| @repo_name = value; n_options+=1 }
    opts.on('-c', '--create', String, 'Create new repo') { @create = true; n_options+=1 }
    opts.on('-m', '--migrate', String, 'Migrate the repo') { @migrate = true; n_options+=1 }
    opts.on('-a', '--add', String, 'Add repo to team') { @add = true; n_options+=1 }
    opts.on('-l', '--language [language]', String, 'Set language of the new repo') { |value| @language = value.strip.downcase; n_options+=1 }
    opts.on('-d', '--debug', 'Print commands for inspection, doesn\'t actually run them') { @debug = true; n_options+=1 }
    opts.on_tail('-h', '--help', 'Prints this little guide') { show_options = true; n_options+=1 }
    @opts = opts
  end.parse!

  if show_options || n_options == 0
    puts @opts
    puts "\nExamples:".c(36)
    puts 'create new repo: ' + "\t\tgitter -c -l javascript -n node_app".c(93)
    puts 'migrate existing to GitHub: ' + "\tgitter -m -n node_app".c(93)
    puts 'create repo and migrate to it: ' + "\tgitter -c -m -l javascript -n node_app".c(93)
    puts 'create repo, migrate to it, and add it to a team: ' + "\tgitter -c -m -a -l javascript -n node_app".c(93)
    puts "\nNotes:".c(36)
    puts "Access Token for repo is #{@access_token} - change this on line 13"
    puts "Team ID for repo is #{@team_id} - change this on line 14"
    puts "Organization for repo is #{@org} - change this on line 15"
    puts 'The assumption is that the person running the script has SSH access to BitBucket,'
    puts 'and GitHub, and that if the current directory contains a directory with the same'
    puts 'name as the repo to migrated, it will deleted and recreated, or created if it'
    puts 'doesn\'t exist - the repo to migrate is mirrored locally, and then created on'
    puts 'GitHub and pushed from that local clone.'
    puts 'New repos are private by default'
    puts "Doesn\'t like symbols for language (ex. use \'c\' instead of \'c++\')"
    puts @sep
    exit
  end
end

#----------------------------------------------------------------------
# git helper methods

def gitter_create(repo)
  if @language
    %q[curl https://api.github.com/orgs/] + @org + %q[/repos -H "Authorization: token ] + @access_token + %q[" -d '{"name":"] + repo + %q[","private":true,"language":"] + @language + %q["}']
  else
    %q[curl https://api.github.com/orgs/] + @org + %q[/repos -H "Authorization: token ] + @access_token + %q[" -d '{"name":"] + repo + %q[","private":true}']
  end
end

def gitter_add(repo)
  if @language
    %q[curl https://api.github.com/teams/] + @team_id + %q[/repos/] + @org + %q[/] + repo + %q[ -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ] + @access_token + %q[" -d '{"permission":"pull","language":"] + @language + %q["}']
  else
    %q[curl https://api.github.com/teams/] + @team_id + %q[/repos/] + @org + %q[/] + repo + %q[ -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ] + @access_token + %q[" -d '{"permission":"pull"}']
  end
end

def git_clone_mirror(bitbucket_origin, path)
  "git clone --mirror #{bitbucket_origin}"
end

def git_push_mirror(github_origin, path)
  "(cd './#{path}' && git push --mirror #{github_origin} && cd ..)"
end

def show_pwd
  if @debug
    Dir.getwd()
  end
end

def git_list_origin(path)
  "(cd './#{path}' && git config remote.origin.url && cd ..)"
end

# error checks

def has_repo
  File.exist?('.git')
end

def has_repo_or_error(show_error)
  @repo_exists = has_repo
  if !@repo_exists
    puts 'Error: no .git folder in current directory'.c(91) if show_error
    @error = true
  end
  "has repo: #{@repo_exists}"
end

def has_repo_name_or_error(show_error)
  @repo_name_exists = !(defined?(@repo_name)).nil?
  if !@repo_name_exists
    puts 'Error: repo name missing (-n your_name_here)'.c(91) if show_error
    @error = true
  end
end

#----------------------------------------------------------------------
# main methods
def run(commands)
  if @debug
    commands.each { |x| puts(x) }
  else
    commands.each { |x| system(x) }
  end
end

def set_globals

  puts_title 'Parameters'

  @git_bitbucket_origin =   "git@bitbucket.org:#{@org}/#{@repo_name}.git"
  @git_github_origin = "git@github.com:#{@org}/#{@repo_name}.git"

  puts 'debug: ' + @debug.to_s.c(93)
  puts 'working in: ' + Dir.pwd.c(93)
  puts 'create: ' + @create.to_s.c(93)
  puts 'migrate: ' + @migrate.to_s.c(93)
  puts 'add: ' + @add.to_s.c(93)
  puts 'language: ' + @language.to_s.c(93)
  puts 'repo name: '+ @repo_name.to_s.c(93)
  puts 'bitbucket: ' + @git_bitbucket_origin.to_s.c(93)
  puts 'github: ' + @git_github_origin.to_s.c(93)
  puts 'team_id: ' + @team_id.to_s.c(93)
  puts 'org: ' + @org.to_s.c(93)
end

def create_repo
  puts_title 'Creating'

  #error checks
  has_repo_name_or_error(true)
  goodbye if @error

  puts @sep

  commands = [
      gitter_create(@repo_name)
  ]

  run commands
end


def add_repo
  puts_title 'Adding repo to team'

  #error checks
  has_repo_name_or_error(true)
  goodbye if @error

  puts @sep

  commands = [
      gitter_add(@repo_name)
  ]

  run commands
end

def migrate_repo

  puts_title "Migrating Repo to #{@repo_provider}"

  #error checks
  has_repo_name_or_error(true)
  goodbye if @error

  if Dir.exists?("#{@repo_name}.git")
    puts "#{@repo_name} already exists... recursively deleting."
    FileUtils.rm_r("#{@repo_name}.git")
  end

  path = "#{@repo_name}.git"
  commands = [
    git_clone_mirror(@git_bitbucket_origin, path),
    git_list_origin(path),
    git_push_mirror(@git_github_origin, path)
  ]

  run commands
end

#----------------------------------------------------------------------
#sequence control
hello
get_options

#do stuff
set_globals
create_repo if @create
migrate_repo if @migrate
add_repo if @add

#peace out
goodbye

그런 다음 스크립트를 사용하십시오.

# create a list of repos
foo
bar
baz

# execute the script, iterating over your list
while read p; do ./bitbucket-to-github.rb -a -n $p; done<repos

# good nuff


답변

있다 GitHub의 가져 오기와 가져 오기 저장소는

다른 버전 제어 시스템에서 Mercurial로 프로젝트를 호스팅하는 경우 GitHub 임포터 도구를 사용하여 자동으로 GitHub로 프로젝트를 가져올 수 있습니다.

  1. 페이지 오른쪽 상단에서을 클릭 한 다음 저장소 가져 오기를 클릭하십시오.
  2. “이전 저장소의 복제 URL”아래에서 가져올 프로젝트의 URL을 입력하십시오.
  3. 리포지토리를 소유 할 사용자 계정 또는 조직을 선택한 다음 GitHub에서 리포지토리 이름을 입력하십시오.
  4. 새 저장소가 공용인지 개인용인지 지정하십시오.
    • 공개 리포지토리는 GitHub의 모든 사용자가 볼 수 있으므로 GitHub의 공동 작업 커뮤니티를 활용할 수 있습니다.
    • 공용 또는 개인 저장소 단일 선택 단추 개인 저장소는 저장소 소유자 및 공유하기로 선택한 모든 협업 자만 사용할 수 있습니다.
  5. 입력 한 정보를 검토 한 다음 가져 오기 시작을 클릭하십시오.

리포지토리를 완전히 가져 오면 이메일이 전송됩니다.

  1. https://help.github.com/categories/importing-your-projects-to-github
  2. https://help.github.com/articles/importing-a-repository-with-github-importer/