I would like to migrate a specific folder from a repo that is in Github to Gitlab. can someone help me with this?
I tried this command sudo gitlab-rake "import:github[access_token,root,foo/bar,foo/github_repo/folder]"
it didn’t work for me. GitHub import | GitLab
can some one help me on this
Hi,
you can only create imports on the project level, not repository directories.
If you are looking for a boring solution with does not preserve Git history, write a script to clone the GitHub repository locally, copy the directory into a new Git repo, and push that to GitLab. The following takes the trick into account to create a private repo on a fresh push.
Should work like below, I wrote that from memory but did not test working.
export PROJECT=project
export USER=user
export DIRECTORY=directory
export GITLAB_NAMESPACE=user
export GITLAB_PROJECT="$PROJECT-$DIRECTORY"
mkdir migration && cd migration
# path for GitLab repo
mkdir -p $GITLAB_PROJECT
git clone https://github.com/$USER/$PROJECT.git
# copy the data into a new repository
cp -rv "$PROJECT/$DIRECTORY/*" "$GITLAB_PROJECT/"
# init, add, remote, push
cd $GITLAB_PROJECT
git init
git add -A
git commit -av -m "Import GH $DIRECTORY to GL $GITLAB_PROJECT"
git remote add origin https://gitlab.com/$GITLAB_NAMESPACE/$GITLAB_PROJECT.git
git push -u origin --all
Cheers,
Michael
1 Like
Thank you Mike for throwing some suggestions. I tried a different approach
- I imported the entire repo of Github to Gitlab
- I deleted the directories that I don’t want from the project in Gitlab
- Now I have the only directory that I want
Problem: I expected that corresponding commits of the directories (deleted directories) will be deleted but it didn’t happen. I still have the same number of commits, branches, Merge requests even after I delete directories. to fix this is there any option that I need to enable?