GitLab – Importing and Exporting Projects in Windows


Synchronizing GitLab with a(Windows) PC

Once you have a GitLab server up and running, you will need to be able to load and save your repositories to it.  Since I have a repository already locally, the first step is to suncrozie my GitLab server with a local copy of my code.  Once completed, I then want to have Android Studio point to it.

Create a Project on GitLab from a local Repository using TortoiseGit

This is done by first creating a repository on the GitLab server with the same name  as it was locally.  I used “Bubbles” as it was the same name as before.  Once that is complete, the GitLab server will generate useful comments 1) how to create a ssh key and 2) how to Import an existing project.

The SSH Key:

Well, remember I generated my SSH key by using the puttyGen on one of the first posts.  I was able to go to ~/.ssh/authorized_keys and see it.  Using putty, on my AWS server I typed

# cat ~/.ssh/authorized_keys

It started with “ssh-rsa” and ended with the “StoneMillEluav” – I was able to simply copy the text into the ssh keys setting in GitLab.  This setting can be found by going to “Profile Settings” and choosing “SSH Keys.”

–

My local .git/config looked like this (I edited my files to not have all my personal info between the {}):

[core]
 repositoryformatversion = 0
 filemode = false
 bare = false
 logallrefupdates = true
 symlinks = false
 ignorecase = true
 hideDotFiles = dotGitOnly
[remote "origin"]
 url = git@www.example_domain.com:{gitlab_username}/Bubbles.git
 fetch = +refs/heads/*:refs/remotes/origin/*
 puttykeyfile = C:\\Users\\{Windows username}\\{rest of the path}\\StoneMillEluav.ppk
[branch "master"]
 remote = origin
 merge = refs/heads/master

My global .gitconfig looked like this(I edited my files to not have all my personal info between the {}):

[user]
 name = Greg S
 email = myEmail@gmail.com
[push]
 default = simple

Tortus git was still pointed to the server with the same name as “Bubbles.”  I CDed into the local “Bubbles” directory and right-clicked “TortusGit->Settings.”  I verified the settings matched.  I then did a git->push to the repo.

All of my files were uploaded successfully, but as I expected, none of the old Issues or milestones were saved.  The reason for that is that info is stored in the database on the AWS server (not in git).

Create a Repo on GitLab and Check it out Locally (without Android Studio)

After creating a default “Jack” project on GitLab, I created a README.md using the links on the webpage.

In GitLab, on the project homepage, there is both an http, and an ssh link.

TortiousGit, simply adds a context menu to the right-click menu in Explorer.  I was simply able to select “git Clone” and point to my new URL on the GitLab server.

I used the ssh link and added my existing ppk. Much easier.

The command line version to create a new repository is as follows:

git clone git@www.example_domain.com:{gitlab_username}/Bubbles.git
cd Bubbles
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

Android Studio and GitLab (without ssh)

Android Studio does not seem to have a way to use the public/private key (easily).  As such, I simply went to VCS->Checkout from Version Control->Git and posted the projects URL using http.  While it is not the safest because it uses unsecured passwords, it allows me to move forward tonight even if I am not as integrated with GitLab and Android Studio as I would have liked.

 

 

 

 

Leave a comment

Your email address will not be published. Required fields are marked *