{"id":819,"date":"2016-10-03T11:33:51","date_gmt":"2016-10-03T06:33:51","guid":{"rendered":"http:\/\/www.stonemillkids.com\/?p=819"},"modified":"2018-12-20T06:20:57","modified_gmt":"2018-12-20T01:20:57","slug":"synchronizing-gitlab-and-your-pc","status":"publish","type":"post","link":"http:\/\/www.stonemillkids.com\/index.php\/2016\/10\/03\/synchronizing-gitlab-and-your-pc\/","title":{"rendered":"GitLab &#8211; Importing and Exporting Projects in Windows"},"content":{"rendered":"<h1>Synchronizing GitLab with a(Windows) PC<\/h1>\n<p><span style=\"font-family: Thread-000020f8-Id-00000138;\">Once you have a GitLab server up and running, you will need to be able to load and save your repositories to it.\u00a0 Since I have a repository already locally, the first step is to suncrozie my GitLab server with a local copy of my code.\u00a0 Once completed, I then want to have Android Studio point to it.<\/span><\/p>\n<h2>Create a Project on GitLab from a local Repository using TortoiseGit<\/h2>\n<p>This is done by first creating a repository on the GitLab server with the same name\u00a0 as it was locally.\u00a0 I used &#8220;Bubbles&#8221; as it was the same name as before.\u00a0 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.<\/p>\n<h3>The SSH Key:<\/h3>\n<p>Well, remember I generated my SSH key by using the puttyGen on one of the first posts.\u00a0 I was able to go to ~\/.ssh\/authorized_keys and see it.\u00a0 Using putty, on my AWS server I typed<\/p>\n<pre># cat ~\/.ssh\/authorized_keys<\/pre>\n<p>It started with &#8220;ssh-rsa&#8221; and ended with the &#8220;StoneMillEluav&#8221;\u00a0&#8211;\u00a0I was able to simply copy the\u00a0text into the ssh keys setting in GitLab.\u00a0 This setting can be found by going to &#8220;Profile Settings&#8221; and choosing &#8220;SSH Keys.&#8221;<\/p>\n<p>&#8211;<\/p>\n<p>My local .git\/config looked like this (I edited my files to not have all my personal info between the {}):<\/p>\n<pre>[core]\r\n\u00a0repositoryformatversion = 0\r\n\u00a0filemode = false\r\n\u00a0bare = false\r\n\u00a0logallrefupdates = true\r\n\u00a0symlinks = false\r\n\u00a0ignorecase = true\r\n\u00a0hideDotFiles = dotGitOnly\r\n[remote \"origin\"]\r\n\u00a0url = git@www.example_domain.com:{gitlab_username}\/Bubbles.git\r\n\u00a0fetch = +refs\/heads\/*:refs\/remotes\/origin\/*\r\n\u00a0puttykeyfile = C:\\\\Users\\\\{Windows username}\\\\{rest of the path}\\\\StoneMillEluav.ppk\r\n[branch \"master\"]\r\n\u00a0remote = origin\r\n\u00a0merge = refs\/heads\/master<\/pre>\n<p>My global .gitconfig looked like this(I edited my files to not have all my personal info between the {}):<\/p>\n<pre>[user]\r\n\u00a0name = Greg S\r\n\u00a0email = myEmail@gmail.com\r\n[push]\r\n\u00a0default = simple<\/pre>\n<p>Tortus git was still pointed to the server with the same name as &#8220;Bubbles.&#8221;\u00a0 I CDed into the local &#8220;Bubbles&#8221; directory and right-clicked &#8220;TortusGit-&gt;Settings.&#8221;\u00a0 I verified the settings matched.\u00a0 I then did a <em>git-&gt;push<\/em> to the repo.<\/p>\n<p>All of my files were uploaded successfully, but as I expected, none of the old Issues or milestones were saved.\u00a0 The reason for that is that info is stored in the database on the AWS server (not in git).<\/p>\n<h2>Create a Repo on GitLab and Check it out Locally (without Android Studio)<\/h2>\n<p>After creating a default &#8220;Jack&#8221; project on GitLab, I created a README.md using the links on the webpage.<\/p>\n<p>In GitLab, on the project homepage, there is both an http, and an ssh link.<\/p>\n<p>TortiousGit, simply adds a context menu to the right-click menu in Explorer.\u00a0 I was simply able to select &#8220;git Clone&#8221; and point to my new URL on the GitLab server.<\/p>\n<p>I used the ssh link and added my existing ppk. Much easier.<\/p>\n<p>The command line version to create a new repository is as follows:<\/p>\n<pre>git clone git@www.example_domain.com:{gitlab_username}\/Bubbles.git\r\ncd Bubbles\r\ntouch README.md\r\ngit add README.md\r\ngit commit -m \"add README\"\r\ngit push -u origin master<\/pre>\n<h2>Android Studio and GitLab (without ssh)<\/h2>\n<p>Android Studio does not seem to have a way to use the public\/private key (easily).\u00a0 As such, I simply went to VCS-&gt;Checkout from Version Control-&gt;Git and posted the projects URL using http.\u00a0 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.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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.\u00a0 Since I have a repository already locally, the first step is to suncrozie my GitLab server with a local copy of my code.\u00a0 Once completed, I then [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":740,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[20,14],"tags":[37,52,31],"_links":{"self":[{"href":"http:\/\/www.stonemillkids.com\/index.php\/wp-json\/wp\/v2\/posts\/819"}],"collection":[{"href":"http:\/\/www.stonemillkids.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.stonemillkids.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.stonemillkids.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.stonemillkids.com\/index.php\/wp-json\/wp\/v2\/comments?post=819"}],"version-history":[{"count":6,"href":"http:\/\/www.stonemillkids.com\/index.php\/wp-json\/wp\/v2\/posts\/819\/revisions"}],"predecessor-version":[{"id":931,"href":"http:\/\/www.stonemillkids.com\/index.php\/wp-json\/wp\/v2\/posts\/819\/revisions\/931"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.stonemillkids.com\/index.php\/wp-json\/wp\/v2\/media\/740"}],"wp:attachment":[{"href":"http:\/\/www.stonemillkids.com\/index.php\/wp-json\/wp\/v2\/media?parent=819"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.stonemillkids.com\/index.php\/wp-json\/wp\/v2\/categories?post=819"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.stonemillkids.com\/index.php\/wp-json\/wp\/v2\/tags?post=819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}