อัปเดตล่าสุด: กุมภาพันธ์ 2026

ย้าย Git จาก Bitbucket ไป GitLab

คู่มือแบบละเอียด - ปี 2025-2026

คู่มือการย้าย Git Repository จาก Bitbucket Cloud และ Bitbucket Server ไปยัง GitLab แบบ Comprehensive พร้อม Troubleshooting

Bitbucket
GitLab
Migration

เนื้อหาในบทนี้

บทนำ

ทำไมต้องย้ายจาก Bitbucket ไป GitLab?

การย้ายจาก Bitbucket ไป GitLab เป็นการตัดสินใจที่สำคัญสำหรับ_teams และองค์กรในปัจจุบัน โดยมีเหตุผลหลักดังนี้:

  • All-in-One Platform - GitLab มี CI/CD, Issue Tracking, Wiki, Container Registry รวมอยู่ในระบบเดียว
  • Cost Effective - GitLab Premium ถูกกว่า Bitbucket Premium สำหรับทีมขนาดกลางถึงใหญ่
  • Self-Managed Option - GitLab มีตัวเลือก Self-Managed ที่ควบคุมได้เต็มที่
  • DevOps Complete Workflow - GitLab ครอบคลุมทุกขั้นตอน DevOps ตั้งแต่ Planning ถึง_monitoring
  • Better Integration - มี integration กับเครื่องมือ DevOps อื่นๆ ครบถ้วนกว่า
1

ข้อมูล Bitbucket และ GitLab

Comparison Table
Bitbucket Cloud (Atlassian) - ผู้ให้บริการ: Atlassian - URL: bitbucket.org - CI/CD: Bitbucket Pipelines - Repository: Git, Mercurial (legacy) - Storage: 1GB Free, 50GB Standard

GitLab.com - ผู้ให้บริการ: GitLab Inc. - URL: gitlab.com - CI/CD: GitLab CI/CD - Repository: Git only - Storage: 10GB Free (Shared), 100GB Premium

สิ่งที่ต้องเตรียม

GitLab Account

สร้างบัญชี GitLab ที่ gitlab.com หรือ GitLab Self-Managed

Bitbucket Credentials

Bitbucket username/password หรือ App Password

Git Knowledge

พื้นฐาน Git commands (clone, push, pull)

Time

ควรเวลาเวลา 1-2 ชั่วโมงต่อ repository ขนาดกลาง

เปรียบเทียบวิธีการย้าย

วิธีการย้ายจาก Bitbucket ไป GitLab

มีอยู่ด้วยกัน 3 วิธีหลัก ขึ้นอยู่กับความต้องการและ resources ของคุณ:

วิธีการ ความง่าย ข้อมูลที่ย้าย เหมาะสำหรับ เวลาที่ใช้
GitLab UI Import ง่ายมาก Repository, Issues, PRs, Wiki, Labels Bitbucket Cloud (ทีมเล็ก-กลาง) 5-30 นาที
Bitbucket Server Import ปานกลาง Repository, PRs, LFS, Comments Bitbucket Server (Self-Managed) 1-8 ชั่วโมง
Git Mirror Clone ปานกลาง-ยาก Repository เท่านั้น (ทุกข้อมูล) ทีมขนาดใหญ่, ต้องการความสมบูรณ์ 10-60 นาที
Manual Push Mirror ยาก Repository เท่านั้น Backup, Sync ระหว่างทั้งสอง 10-60 นาที

คำแนะนำจากผู้เชี่ยวชาญ

สำหรับ Bitbucket Cloud: ใช้ GitLab UI Import - ง่ายและปลอดภัยที่สุด
สำหรับ Bitbucket Server: ใช้ Bitbucket Server Import หรือ Git Mirror
สำหรับทีมขนาดใหญ่: วางแผน migration แบบ step-by-step, test กับ repository เล็กก่อน

ย้ายจาก Bitbucket Cloud ด้วย GitLab UI

ขั้นตอนการย้าย Bitbucket Cloud แบบใช้ GitLab Import Tool

GitLab มี Import Tool ที่รองรับ Bitbucket Cloud อย่างเป็นทางการ สามารถย้าย repository, issues, merge requests, wiki และ metadata อื่นๆ ได้ทั้งหมด

1

สร้าง App Password สำหรับ Bitbucket

ก่อนเริ่ม import ต้องสร้าง Bitbucket App Password ที่มีสิทธิ์อ่าน repository ทั้งหมด:

Bitbucket Settings
# 1. เข้า Bitbucket Settings: https://bitbucket.org/account/settings/

# 2. ไปที่ App passwords ด้านล่าง

# 3. Create app password พร้อม permissions: Account: Email, Read Projects: Read Repositories: Read Pull Requests: Read Issues: Read Wiki: Read and Write

# 4. Copy password (จะแสดงครั้งเดียว!)
2

เริ่ม Import ผ่าน GitLab Web UI

GitLab Web Interface
# 1. เข้า GitLab และ Sign in https://gitlab.com/users/sign_in

# 2. สร้าง Project ใหม่: # Click: Create new → New project/repository

# 3. เลือก Import project → Bitbucket Cloud

# 4. Sign in to Bitbucket ด้วย Bitbucket credentials

# 5. Grant access ให้ GitLab

# 6. เลือก repositories ที่ต้องการ import # - เลือก project หรือ All projects # - เลือก namespace (group) ปลายทาง

# 7. Click Import

ข้อมูลที่ถูกย้ายจาก Bitbucket Cloud

Item State Comment
Repository ✓ Imported ทุก branch, tag, commit history
Issues ✓ Imported พร้อม comments และ assignees
Merge Requests ✓ Imported พร้อม comments และ reviewers
Wiki ✓ Imported All pages
Labels ✓ Imported Label colors preserved
Milestones ✓ Imported With due dates
LFS Objects ✓ Imported Large file storage
PR Approvals ✗ Not imported GitLab approval rules เป็นอีกระบบ
PR Rules ✗ Not imported ต้องตั้งใหม่ใน GitLab
3

ตรวจสอบหลัง Import สำเร็จ

Verify Import
# ตรวจสอบใน GitLab Web UI:

# 1. Repository ดู: Files, branches, tags # 2. Issues ดู: Issues → All issues # 3. Merge Requests ดู: Merge requests # 4. Wiki ดู: Project → Wiki

# ใน GitLab (items ที่ถูก import จะมี badge "Imported")

User Mapping (การแมপผู้ใช้)

GitLab จะพยายามแมป Bitbucket(username) กับ GitLab ข้อมูลดังนี้:

  • พยายาม match ด้วย username ของ Bitbucket
  • ถ้าไม่เจอ จะใช้ people ที่เริ่ม import เป็น author
  • Reference จะถูกเก็บไว้ใน comment ของ issue/PR

สำหรับ user mapping ที่แม่นยำ ควร login ด้วยบัญชีที่ตรงกันก่อน import

ย้ายจาก Bitbucket Server (Self-Managed)

Bitbucket Server Import สำหรับ GitLab Self-Managed

สำหรับทีมที่ใช้ Bitbucket Server (เดิมเรียก Stash) และ GitLab Self-Managed การ import ต้องใช้ Bitbucket Server credentials ที่มี admin access

Prerequisites

Network Access

GitLab ต้องเข้าถึง Bitbucket Server ได้ (public หรือ internal network)

Admin Token

Bitbucket Server admin personal access token

GitLab Role

Maintainer role บน destination group

1

สร้าง Bitbucket Server Token สำหรับการเข้าถึงส่วนบุคคล

Bitbucket Server Admin
# 1. เข้าBitbucket Server Admin: http://your-bitbucket-server:7990/admin

# 2. ไปที่การตั้งค่าผู้ใช้ → Token สำหรับการเข้าถึงส่วนบุคคลs

# 3. Create new token with scopes: - PROJECT_READ - REPO_READ - ADMIN_REPO_HOOKS - ADMIN_PROJECT_REPOS

# 4. Copy token (จะแสดงครั้งเดียว!)
2

Import ผ่าน GitLab Web UI

GitLab Web Interface
# 1. GitLab → Create new → New project/repository

# 2. Select Import project → Bitbucket Server

# 3. Enter Bitbucket Server URL: https://your-bitbucket-server:7990 # (หรือ https://bitbucket.yourcompany.com)

# 4. ใส่ชื่อผู้ใช้และ Token สำหรับการเข้าถึงส่วนบุคคล

# 5. Click Authenticate

# 6. Select projects to import

# 7. Click Import

ข้อมูลที่ย้ายจาก Bitbucket Server

Item Imported Notes
Repository ✓ Yes Full commit history
PRs + Comments ✓ Yes รวม reviewers และ comments
LFS Objects ✓ Yes Large file storage
Comments on code ✓ Yes Out-of-bounds ถูก insert เป็น MR comment
Project filters Partial ไม่ support fuzzy search
Attachments in MD ✗ No ต้องย้าย manually
Task lists ✗ No ไม่ import

Estimate Import Duration

เวลาในการ import ขึ้นกับขนาดของ repository:

Size PRs Tags Estimated Time
Small <100 <10 10-30 min
Medium 100-1,000 10-100 30-60 min
Large 1,000-10,000 100-1,000 1-4 ชม.
XLarge >10,000 >1,000 4-8 ชม.+

ตัวอย่าง: project ขนาด 500GiB, 13,000 PRs, 7,000 tags ≈ 8 ชั่วโมง

ใช้ Git Mirror (Advanced Method)

Git Mirror Clone + Push Method

วิธีนี้เหมาะสำหรับทีมที่ต้องการควบคุมทุกอย่างด้วยตนเอง หรือต้องการ mirror ระหว่าง Bitbucket และ GitLab พร้อมกัน

1

Clone จาก Bitbucket ด้วย --mirror

Local Machine
# Clone แบบ mirror ( clones ทุก branch, tag, ref) git clone --mirror https://bitbucket.org/username/repo.git repo-mirror.git

# หรือใช้ SSH: git clone --mirror git@bitbucket.org:username/repo.git repo-mirror.git

# เข้า directory ที่ clone มา cd repo-mirror.git

# ดู list ของ branches และ tags ที่ถูก clone git branch -a git tag -l
2

Push ไปยัง GitLab ด้วย --mirror

GitLab Setup
# 1. สร้าง repository ใหม่ใน GitLab # - URL: https://gitlab.com/username/repo.git # - อย่าInitialize README หรือ LICENSE

# 2. Add GitLab remote git remote add gitlab https://gitlab.com/username/repo.git

# 3. Push ทุกอย่างไปยัง GitLab git push --mirror gitlab

# 4. ตรวจสอบ git remote -v

Push Mirror Configuration (ตั้งค่าsync อัตโนมัติ)

ตั้งค่าให้ GitLab ดึงข้อมูลจาก Bitbucket อัตโนมัติ:

GitLab Project Settings
# ใน GitLab UI: # Project → Settings → Repository # ขยาย Mirroring repositories section

# Push to a remote repository: Repository URL: https://bitbucket.org/username/repo.git Username: your-username Password: your-bitbucket-password-or-token

# หรือ Pull from a remote repository: Repository URL: https://bitbucket.org/username/repo.git Mirror repository settings: Enable

ข้อควรระวังของ Git Mirror Method

  • วิธีนี้จะ copy only Git repository data (ไม่มี issues, PRs, wiki)
  • ต้องมี SSH keys หรือ credentials ที่ตรงกัน
  • ถ้าใช้ Token สำหรับการเข้าถึงส่วนบุคคล ต้องมี permissions ที่ถูกต้อง
  • แนะนำให้ test กับ repository เล็กก่อน

Troubleshooting

Common Issues และวิธีแก้ไข

1

Import fails: "Repository not found" หรือ "Unauthorized"

สาเหตุ: App password ไม่มีสิทธิ์หรือหมดอายุ

# แก้ไข: # 1. สร้าง Bitbucket App Password ใหม่ # 2. ตรวจสอบ permissions (Account Read, Projects Read, Repositories Read) # 3. Copy password ที่ถูกต้อง (ไม่มี space)
2

Import fails: "Import URL is blocked"

สาเหตุ: ตัว Bitbucket server หรือ reverse proxy ตั้งค่าไม่ถูกต้อง

# แก้ไข: # 1. ตรวจสอบ Bitbucket server รู้จัก proxy server หรือไม่ # 2. ตั้ง reverse proxy ให้ส่ง correct headers # 3. ใช้ API check import_url value

# ใช้ GitLab API: curl -H "PRIVATE-TOKEN: your-token" "https://gitlab.com/api/v4/projects?search=repo-name"
3

User mapping ผิดพลาด

สาเหตุ: Bitbucket username ไม่ตรงกับ GitLab username

# แก้ไข: # 1. Check Bitbucket account settings → Public name # 2. Ensure public name matches GitLab username # 3. Reconnect Bitbucket in GitLab profile # 4. Delete and re-import project
4

LFS objects not imported

สาเหตุ: Special characters ใน password/token

# แก้ไข: # 1. สร้างApp password / token ใหม่ ไม่มี special chars # 2. ใช้ URL-encoded ถ้าจำเป็น # 3. หรือใช้ SSH keys แทน

General Tips

  • Test First: เริ่มจาก repository เล็กก่อน
  • Backup: สำรองข้อมูลจาก Bitbucket ก่อนย้าย
  • Off-Hours: ย้ายในเวลาที่มีคนใช้น้อย
  • Monitor: ตรวจสอบ progress ใน GitLab import log