Export Git Contributions to GitHub

Importing your contributions from other platforms or private git to Github.

Posted by PeCoBe on 2024-03-17 ·

How to Import Contributions from Bitbucket to GitHub

Are you ready to showcase your hard work and dedication on GitHub, but your contributions are scattered across Bitbucket? No worries! In this guide, we'll walk you through the process of importing your contributions from Bitbucket to GitHub effortlessly.

This process is useful for cses when your organization is working with private repositories, or bitbucket. Not everyone is using Github now, but still recruiters tend to look at the contributions made by candidates. So in order to just keep it up on visible for other to see, this is a nice tool.

Based on Daniel Mai post about importing contributions and Contributions-Importer-For-Github by miromannino

Steps:

  1. Install pipenv Before diving into the process, make sure you have pipenv installed on your system. If not, you can easily install it using pip.

  2. Set Up a Mock Repository on GitHub To begin, create an empty repository on your GitHub account. This will serve as our mock repository where we'll simulate the contributions from Bitbucket.

img

  1. Clone the Empty Repository Clone the empty repository onto your local machine using the git clone command.

img

  1. Clone the Contributions Importer Tool Next, clone the Contributions Importer For GitHub tool onto the same parent folder as your empty repository. This tool will help us facilitate the import process seamlessly.
git clone https://github.com/miromannino/Contributions-Importer-For-Github.git

  1. Configure and Run the Importer Script Inside the Contributions Importer For GitHub folder, create a new Python script and name it as you prefer. Then, add the following code to the script:
#!/usr/bin/python3
import git
from src import *

repos_path = [
    "/path/to/repo2/",
    "/path/to/repo1/"
]
repos = []
for repo_path in repos_path:
    repos.append(git.Repo(repo_path))

mock_repo_path = git.Repo("/path/to/mock/repo/")
mock_repo = git.Repo.init(mock_repo_path)

importer = Importer(repos, mock_repo)
importer.set_author(['personal@email.com', 'work@email.com'])

importer.import_repository()

This script will handle the import process from Bitbucket to GitHub. Make sure to replace the placeholders with your actual repository paths and email addresses.

Lets explain the script

import git
from src import *

This will import the libraries git and src. The src library is the one from the Contributions-Importer-For-Github.

repos_path = [
    "/path/to/repo2/",
    "/path/to/repo1/"
]

List of private repositories, from where we want to get the contributions (Source).

repos = []
for repo_path in repos_path:
    repos.append(git.Repo(repo_path))

Iterate thru the list of repositories and add them to a list.

mock_repo_path = git.Repo("/path/to/mock/repo/")
mock_repo = git.Repo.init(mock_repo_path)

Path to the mock repo (Target). This is the empty repository we prepared before, and this repository will be fill with files to simulate the contributions made on the source repositories.

importer = Importer(repos, mock_repo)
importer.set_author(['personal@email.com', 'work@email.com'])

Initialize the importer. The set author parameter will allows us to select the author of the contributions. You need to add here the email of the author for the source repositories and also the email for the target repository.

  1. Execute the Importer Script Once the script is set up, create a new virtual environment for Python and install the required packages using pip.
pip3 install gitpython
pip3 install pathlib

Navigate to your mock repository directory and run the importer script.

python3 ../Contributions-Importer-For-Github/your_script_name.py
  1. Verify and Commit Sit back and relax as the script imports your contributions. Once it's finished, verify that your mock repository now contains the simulated contributions. Commit and push these changes to your GitHub repository.

img

  1. Admire Your Matching Contributions

Visit your GitHub profile and behold! Your contributions from Bitbucket are now proudly displayed, matching your activity on GitHub.

img

Conclusion

With this straightforward process, you can seamlessly import your contributions from Bitbucket to GitHub, allowing you to showcase your dedication and hard work in one centralized location.

Congratulations on completing the import, and keep up the great work!

Thanks for reading, and happy coding!