Migrate from bitbucket to GitLab - version-control

I have multiple repositories in BitBucket. What is the most appropriate way to migrate from BitBucket to GitLab?
For an example, I maintain a repo on my system named "SSSP". What should be my steps to have a clean migration of that repository from BitBucket to GitLab?

It is better to use an intermediate local bare repo in order to duplicate one remote repo and push it to a new remote one.
Assuming you have an empty gitlab repo ready:
git clone --bare git#bitbucket.com:old/old_repo.git
cd old_repo
git remote add new-origin git#gitlab.com:new/new_repo.git
git push --mirror new-origin
cd ..
git clone git#gitlab.com:new/new_repo.git repo
cd repo
# start working
Note that this won't include the wiki (which you need to clone as well if you have some content there), or the issues.

I suppose that using the import feature via web interface will be simpler than cloning and pushing each repo.
GitLab Documentation - Import your project from Bitbucket to GitLab
Also, Gitlab can import issues in that case.

I had this issue today and the links in the above answer out of date (404 Not Found). Finally I solved it and here's the steps how i made it and hope it helps for people who need it
Step1: Bitbucket
login your bitbucket account
got to Bitbucket settings
select OAuth(on left side menu)
select Add consumer
fill in details:
Name
description
Callback URL
URL
grant permissions
Account: Email, Read
Repositories: Read
Pull Requests: Read
Issues: Read
Wiki: Read and Write
save your changes
Now the key and secret are generated like:
Step2: GitLab
open gitlab.rb file as root using vim(you can choose your preferable editor)
sudo vim /et/gitlab/gitlab.rb
initialize OmniAuth Configuration for initial settings:
gitlab_rails['omniauth_enabled'] = true
gitlab_rails['omniauth_allow_single_sign_on'] = ['saml', 'twitter']
gitlab_rails['omniauth_auto_link_ldap_user'] = true
gitlab_rails['omniauth_block_auto_created_users'] = true
add Bitbucket provider configuration(key and secret we generated):
gitlab_rails['omniauth_providers'] = [
{
"name" => "bitbucket",
"app_id" => "BITBUCKET_APP_KEY",
"app_secret" => "BITBUCKET_APP_SECRET",
"url" => "https://bitbucket.org/"
}
]
save the changes to gitlab.rb file
run command gitlab-ctl stop, gitlab-ctl reconfigure and gitlab-ctl start to reconfigure the changes and restart gitlab.
Now you can see this confirmation modal:

I don't have 50 reputation so I can't comment but VonC is right. Spent about two hours trying to get GitLab's BitBucket import feature to work - I trashed it and simply added a new origin, re-pushed --mirror and deleted the older origin. When looking at the new GitLab server, I can see all the commits from the previous Git origin / server.
cd /dev-git-repo/
git remote add new-origin https://my-gitlab.my-gitlab-repo.com/myrepo-dev-git-repo
git push --mirror new-origin
git remote remove origin
Then you can test ...
echo "\r\nThis should be seen on GitLab not bitBucket" > README.md
git commit -m "updated readme.md"
git push new-origin
And you can see README was updated on gitlab and not on bitbucket.

In case you use bitbucket-server and gitlab-ce.
First, open gitlab-ce admin interface, create a new group bitbucket-import. Afterwords create a new project within that group so that the folder /var/opt/gitlab/data/repositories/bitbucket-import should get created.
Then, copy the bare repositories from bitbucket-server data folder to gitlab-ce data folder:
cp -r /var/atlassian/application-data/stash/shared/data/repositories/* /var/opt/gitlab/data/repositories/bitbucket-import
Rename all folders from {folder} to {folder}.git. Gitlab-ce needs the .git ending to import the repository.
/var/opt/gitlab/data/repositories/bitbucket-import/
rename -n s/$/.git/ * # Dry run
rename s/$/.git/ * # Renaming
Import the repositories:
chown -R git:git /var/opt/gitlab/data/repositories/bitbucket-import/
gitlab-rake gitlab:import:repos['/var/opt/gitlab/data/repositories/'] RAILS_ENV=production
Now, you can see the imported git repositories in your gitlab admin interface represented through bitbucket id's. Here is how you can lookup the real name:
http://your-bitbucket-stash-server/rest/api/1.0/repos?limit=1000&start=0
Go to gitlab-ce project settings -> Advanced and rename your repositories.
Kind regards.

1.git -c http.sslVerify=false clone https://user#bitbkt:8443/scm/config.git
Will create clone from bitbucket on Local machine(Need proper rights for cloning the data from Bitbucket)
2.cd config
after cloning go into base folder
3.git remote add sxm https://test.com/gitlab/xyz/config.git
Had created specific group on GitLab(xyz) and created config project in it.
4. git push sxm
Will push BitBucket code on GL Gitlab.

Related

Error message"...No such file or directory" when trying to set up project to inteact with Git

Using the following programs and interfaces:
R-4.2.2 for Windows
RStudio Desktop: Open Source Edition (AGPL v3)
Git Bash
GitHub
I am currently in the early stages of a tech program learning Data Analytics.
On my PC, working within RStudio, I've created a project that is currently not under version control. I am trying to get it set up to interact with Git.
When I type in my command (cd ~/dir/name/of/path/to/file) for it to move around and navigate to the directory containing my files, I keep getting this error message:
bash: cd: /c/Users/Administrator.STEPHHOWERTON/dir/name/of/path/to/file: No such file or directory"
I've tried creating different pathways. My original directory pathway was:
cd: /c/Users/Administrator.STEPHHOWERTON/RStudio Projects/Temporary_add_to_version_control
Then I tried to simplify by creating a easier path like the example in my module:
c/Desktop/Temporary_add_to_version_control
No luck with either.
I went ahead to try initialize the directory to as a Git repository and also tried to add files, but of course it said the directory was empty.
Any help would be greatly appreciated.
It is best to switch to command line (simple CMD, no bash required), after having installed Git for Windows.
Go to the root folder of your repository (not path/to/file, but path/to/root/folder/of/repository), where your project is.
You can then create a repository
git init .
git add .
git config --global user.name "your name"
git config --global user.email "your#email.com"
git commit -m "Import project"
If you need to create a GitHub repository and push your project, you can, from that same folder, after installing GitHub CLI gh, use gh auth login (with a classic PAT, scope repo):
gh auth login --with-token < echo ghp_...
Then gh repo create:
gh repo create my-project --public --source=. --push
You can reopen RStudio from there, and check everything is working.

Why is it appearing like I have pushed my code to github but I got to my profile and the code is not there?

What am I doing wrong?
Why will my code not show on github even though it appears to have pushed saying clean tree.
What am I supposed to be entering when it asks for git credentials osxkeychain?
Hello I have been watching video after video and reading the documentation on github and how to use it but nothing seems to be working. I have created a repo in my account and done the following:
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/stephBrandon/PythonNumberGuessingGame.git
git push -u origin main
it responded by saying initialized empty git repo in my folder which is true when hitting ls -a there is a .git file and there is a readme now as well
But when checking on my github none of the code it there and in the terminal it seems to be trying to access my old git hub account instead of my new one and I have no idea what to do now.
remote: Permission to stephBrandon/PythonNumberGuessingGame.git denied to stephanieBrandon.
fatal: unable to access 'https://github.com/stephBrandon/PythonNumberGuessingGame.git/': The requested URL returned error: 403```
I had issues with the keycode and went into my key chain to see if I could change it there or if I was entering the wrong password but the one I had I deleted and it wont allow me to add another like some other videos I have watched.
Please help. I just want to know how to start using GitHub as I am in year 2 of my program and want to have a visible portfolio of my work without the frustrations of not figuring out how to use GitHub and it always seeming to take longer to upload to GitHub then the projects themselves sometimes.
If I am missing something in my explanation above here is a copy of the terminal
```(base) stephaniebrandon#Stephanies-MacBook-Pro-2 Lab4Random % git commit -m "First commit for Python Guessing Game"
[main e955053] First commit for Python Guessing Game
1 file changed, 44 insertions(+)
create mode 100644 lab4.py
(base) stephaniebrandon#Stephanies-MacBook-Pro-2 Lab4Random % git remote add origin https://github.com/stephBrandon/PythonNumberGuessingGame.git
error: remote origin already exists.
(base) stephaniebrandon#Stephanies-MacBook-Pro-2 Lab4Random % git remote add origin https://github.com/stephBrandon/PythonNumberGuessingGame.git
git branch -M main
git push -u origin main
error: remote origin already exists.
remote: Permission to stephBrandon/PythonNumberGuessingGame.git denied to stephanieBrandon.
fatal: unable to access 'https://github.com/stephBrandon/PythonNumberGuessingGame.git/': The requested URL returned error: 403
(base) stephaniebrandon#Stephanies-MacBook-Pro-2 Lab4Random % ls -a
. .. .git README.md lab4.py```
Additionally, when I try to do
```git push -u origin main```
it doesn't do anything but enter a loop that I have to control c to get out of.
If you are okay with using SSH instead of HTML, this should be the easiest way. This is assuming you have not local .git folder (you can delete it if you don't have git history you'd like to save).
Part 1: Set up SSH with GitHub
First, open your terminal and run this command:
ssh-keygen -b 4096 -t rsa
When it asks you for a file name and save location, just hit ENTER to use defaults. Unless you feel it is necessary you can skip the password requirement the same way.
This will create a new (hidden!) folder named .ssh and two files in it: id_rsa and id_rsa.pub. id_rsa.pub is your public key. This is how you will authenticate with GitHub. Never share your private key (the other file).
Now, go to GitHub and sign in normally. Then, go to your profile settings (pictured below).
Then to this setting...
And hit this green button:
Give it any title you'd like, such as the name of your computer, and paste in the contents of your id_rsa.pub file into the box and hit "Add SSH key". You should be able to open either of the two rsa_id files with any text program.
Part 2: Setting up a Repo
In my experience, the easiest way to get Git configured correctly is to do this method rather than setting the upstream yourself.
First, make a new repository on GitHub. It doesn't matter if it's private or public, but add at least one file (such as a readme or .gitignore) to generate the first commit.
Now, you should be directed to your new repo. If you get a weird screen telling you to run some commands you likely didn't add any files when setting up the repo.
Assuming that you see the page, however, click the "code" button on the top right and select SSH. Copy it to the clipboard. (pictured below)
Part 3: Setting up your local repo
Open your terminal of choice and run
git clone git#github.com:[your details here].git
It should clone the repo and set the upstream for you. If you get an error here you likely have issues with your SSH settings.
Once you have the repo cloned, drag in any project you'd like and treat it like normal!
git status
git add *
git commit -m "Your message"
git push
Hope that works for you! Let me know if you have any problems.

Jupyter Notebook file is taking forever to upload on Github

I was trying to upload one of my Jupyter Notebook files on GitHub, but it's taking forever to upload.
File size is also not that big. It's about 17KB. Also getting problem for this notebook only.
Here's the screen shot.
Any kind of help or suggestions are highly appreciated.
Try using Git Bash to push your code/make changes instead of uploading files directly on GitHub (it is less prone to errors and is quite comfortable at times - takes less time as well!), for doing so, you may follow the below-given steps:
Download and install the latest version of Git Bash from here - https://git-scm.com/
Right-click on any desired location on your system.
Click “Git Bash Here”.
git config --global user.name “your name”
git config --global user.email “your email”
Go back to your GitHub account – open your project – click on “clone” – copy HTTPS
link.
git clone PASTE HTTPS LINK.
Clone of your GitHub project will be created on your computer location.
Open the folder and paste your content.
Make sure content is not empty
Right-click inside the cloned folder where you have pasted your content.
Click “Git Bash Here” again.
You will find (master) appearing after your location address.
git add .
Try git status to check if all your changes are marked in green.
git commit --m “Some message”
git push origin master
Hope this helps! Good luck!
You could try and:
clone the repository, add the file locally, commit and push
check on github.com if your remote repository has a .gitattributes file with lfs directives in it.
Maybe that repository, managed by LFS, has reached some upload limit which would prevent any new upload.

Rstudio: Changing origin for git version control of project

I originally set up git in Rstudio while enrolled in the Data Scientist's Toolbox course at Coursera. Unfortunately, I did this in my phd project. The repository no longer exists on github. I am now attempting to write my thesis in rmarkdown using knitr and bookdown. I would like to use version control, both to learn proper git workflow and to have a structured back up of everything I have done in my thesis. However, I have been unable to change the version control repository in Rstudio.
I am unable to change this in the Tools > Version control > Project setup > Git/SVN menu. The Origin: textbox is unchangable.
I tried creating a new project using the old phd project's working directory. This also cloned the version control settings.
How do I change the origin to accomplish what is described above?
Git, Github and Rstudio are different things. You could use git as local version control tools. You might connect your local repo to Github account which is based on git by push/pull. Rstudio just makes a user interface for git and supplies the function to push the repo into remote server based on git to make version control(not only Github, but also Gitlab).
So for your issue, if you do not want to pay for github for a private repo, all of your code would be public and I don't think it is good before your finally finished your thesis. But version control could be made locally with git only. Just use git shell to control the version.
However, as a student, github could support private repo here for you. Just register and find your student package. Then just remove the url for remote repo after you cd to your workdir in command line, use the following code to find your remote url(mostly you might fing origin):
git remote -v
Then use this to remove them:
git remote rm origin
Now you could use version control locally. If you want to connect this repo to your remote github private repo, use this:
git remote add origin https://github.com/[YourUsername]/[YourRepoName].git
RStudio would find this information about git and support your following operation. Project in RStudio is different with git, although project support git as version control tool. So you need git in command line or shell to solve your problem.
This can be done by opening /your.project/.git/config
and editing the remote origin line(s), e.g. changing from git to https.
Restart Rstudio & you'll be prompted for your github username & password.
This is what worked for me for migrating from github to Azure
Go to the top right Git window in RStudio and click on the gear. Now click Shell (to open the terminal there).
#remove origin
git remote rm origin
#add new origin like Azure for me via HTTPS
git remote add origin https://USER#dev.azure.com/USER/PROJECT/_git/REPONAME
#push your local repro
git push -u origin --all
#in my case put in the PAT password if you needed to generate one.
After testing, I found some clue
Actually Rstudio is not really smart about this setting
It will first search for the git file in the Rproject folder where your Rporject file is located
if it could not, then it goes up to the folder contains your Rproject folder
However, for version control you only need coding files while RProject may contains some big files like .RData some pictures etc.
I don't find a way to manually disrupt this logic flow, the only thing you can do is to delete the current git repository setting files(which is .git folder and 2 other git setting files), then Rstudio may ask you if you want to init a new one.

Backup and restore libgdx projects on Eclipse

I'm having trouble to working with a libgdx project on two computers.
What is the best way to backup in one computer and then restore on another?
I use the google-play-services and BaseGameUtils and have to re-importing all time.
For that i recommand to use Git, if it's new to you here are the main steps to get start :
1 - Create an account at Bitbucket : you can put your code in private mode and it's free
2 - Download and Install TortoiseGit tool: it really make life easier
3 - Create your (in Server) repository in bitbucket
4- Create your repository in Local
5 - Match between your repositories using these commands :
cd /path/to/my/repo
git remote add origin https://minos23#bitbucket.org/minos23/rep2.git
git push -u origin --all # pushes up the repo and its refs for the first time
git push -u origin --tags # pushes up any tags
You can now pull(download)/push(upload) your code with one click !!
Hope that was clear and helpful ! Good luck