import-gitlab-commits

command module
v0.0.0-...-26f967c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2025 License: MIT Imports: 8 Imported by: 0

README

Import GitLab Commits

Go Report Card

This tool imports commits from a private GitLab repository to a separate repository. It can be used to showcase your programming activity for another company on GitHub.

Check out this informative blog post for a practical use case on how to import GitLab commits here.

Why It's Useful

Contributions before running import-gitlab-commits:

Screenshot of GitHub contributions graph before running import-gitlab-commits

After:

Screenshot of GitHub contributions graph after running import-gitlab-commits with a lot of activity

Getting Started

  1. Download and install Go.

  2. Install the program by running the following command in a shell:

    go install github.com/alexandear/import-gitlab-commits@latest
    
  3. Set environment variables and run import-gitlab-commits:

    export GITLAB_BASE_URL=<your_gitlab_server_url>
    export GITLAB_TOKEN=<your_gitlab_token>
    export COMMITTER_NAME="<Name Surname>"
    export COMMITTER_EMAIL=<mail@example.com>
    
    $(go env GOPATH)/bin/import-gitlab-commits
    

Where:

  • GITLAB_BASE_URL is a GitLab instance URL, e.g., https://gitlab.com, https://gitlab.gnome.org, or any GitLab server.
  • GITLAB_TOKEN is a personal access token.
  • COMMITTER_NAME is your GitHub name with surname, e.g., John Doe (can be passed to git config user.name).
  • COMMITTER_EMAIL is your GitHub email, e.g., john.doe@example.com (valid for git config user.email).
  • $(go env GOPATH)/bin/ is the path where import-gitlab-commits is installed.

Internals

What the tool does:

  • Retrieves current user info using GITLAB_TOKEN.
  • Fetches projects from GITLAB_BASE_URL that the current user contributed to.
  • For all projects, fetches commits where the author's email matches the current user's email.
  • Creates a new repository repo.gitlab.yourcompany.com.currentusername and commits all fetched commits with the message: Project: GITLAB_PROJECT_ID commit: GITLAB_COMMIT_HASH, commit date GITLAB_COMMIT_DATE, and commit author COMMITTER_NAME <COMMITTER_EMAIL>.

To display the changes on GitHub, you need to:

  • Create a new repository yourcompany-contributions on GitHub.
  • Open the folder repo.gitlab.yourcompany.com.currentusername.
  • Add the remote URL: git remote add origin git@github.com:username/yourcompany-contributions.git.
  • Push the changes.
Integration Tests

To run integration tests:

  1. Set the GITLAB_TOKEN environment variable with the value obtained at https://gitlab.com/-/user_settings/personal_access_tokens. Necessary scopes:

    • read_api
    • read_user
    • read_repository
  2. Set GITLAB_BASE_URL to https://gitlab.com.

  3. Run make test-integration.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package app provides the core functionality for the import-gitlab-commits application, including initializing the GitLab client, fetching user information, and importing commits into a local git repository.
Package app provides the core functionality for the import-gitlab-commits application, including initializing the GitLab client, fetching user information, and importing commits into a local git repository.
testutil
Package testutil provides utilities for testing, including test-friendly logging.
Package testutil provides utilities for testing, including test-friendly logging.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL