{"id":576,"date":"2015-07-14T16:18:02","date_gmt":"2015-07-14T11:18:02","guid":{"rendered":"http:\/\/www.stonemillkids.com\/?p=576"},"modified":"2019-05-17T05:23:12","modified_gmt":"2019-05-17T00:23:12","slug":"gitlab-setting-up-android-studio","status":"publish","type":"post","link":"http:\/\/www.stonemillkids.com\/index.php\/2015\/07\/14\/gitlab-setting-up-android-studio\/","title":{"rendered":"GitLab &#8211; Syncing with a Local Repo"},"content":{"rendered":"<p>In this post I will be creating a project on GitLab and Syncing my local files with it.\u00a0 Here are links to the previous posts for setting up GitLab and changing the default\u00a0Labels.<\/p>\n<h3>Background<\/h3>\n<p>I have a project that I created on GitLab called &#8220;Shapes&#8221;\u00a0 that contains a single\u00a0Readme.txt.\u00a0 I have a folder called Shapes on my\u00a0PC that contains a\u00a0src and a doc folder.\u00a0 I\u00a0all of my local files to be part of the repository on the server.<\/p>\n<p><em>Note:\u00a0 These steps are not exactly clean so do not follow them exactly.\u00a0 Meaning I made a couple of mistakes (I&#8217;ll point them out as I go along) and blindly following these directions will do what I need, but it was the long way to get there.\u00a0 I am documenting them for future reference.\u00a0 Maybe the next time I create a project, I&#8217;ll update these instructions to be as small as possible.<\/em><\/p>\n<p><em>Also please note that my experience with git is less than that of GitLab, so every command I found I had to google and\/or read about before entering.\u00a0 Again, I am documenting this for my own purposes.<\/em><\/p>\n<p>When starting a project, GitLab offers these few examples as to how to create the repository (It also fills the examples with your exact settings so it is every easy).\u00a0 However, I could not use these because I had already created an example project with GitLab by adding a Readme.txt and I had code on my PC.\u00a0 If you are just starting, I suggest using one of their examples.<\/p>\n<h3>GitLab Instructions<\/h3>\n<pre>Git global setup\ngit config --global user.name \"FirstName LastName\"\ngit config --global user.email \"email@example.com\"\n<\/pre>\n<h3>Create a new repository<\/h3>\n<pre>git clone git@www.stonemillkids.com:username\/Shapes.git\ncd Shapes\ntouch README.md\ngit add README.md\ngit commit -m \"add README\"\ngit push -u origin master\n<\/pre>\n<h3>Existing folder or Git repository<\/h3>\n<pre>cd existing_folder\ngit init\ngit remote add origin git@www.stonemillkids.com:username\/Shapes.git\ngit push -u origin master\n<\/pre>\n<h3>What I did<\/h3>\n<p>I had a Shapes Readme.txt (If I did not, I could have followed the directions above).\u00a0 Doing it a 2nd time I might consider deleting the Shapes project from the server and starting over.<\/p>\n<p>On the PC I created a repository and tried to link it to the server.\u00a0 I did something wrong so the remote did not sync correctly.<\/p>\n<pre>$ cd Shapes\n$ls\n\/src \/doc\n$ git init Shapes\n<\/pre>\n<p>I then checked out the server repository and then merged what I had locally to the remote repository<\/p>\n<pre>$ git pull http:\/\/www.stonemillkids.com:XX\/username\/Shapes.git\n Username for 'http:\/\/www.stonemillkids.com:XX': username\n Password for 'http:\/\/username@www.stonemillkids.com:XX':\n warning: no common commits\n remote: Counting objects: 3, done.\n remote: Total 3 (delta 0), reused 0 (delta 0)\n Unpacking objects: 100% (3\/3), done.\n From http:\/\/www.stonemillkids.com:XX\/username\/Shapes\n * branch\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 HEAD\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 -&gt; FETCH_HEAD\n Merge made by the 'recursive' strategy.\n Readme.txt | 1 +\n 1 file changed, 1 insertion(+)\n create mode 100644 Readme.txt<\/pre>\n<pre>$ git status\n On branch master\n nothing to commit, working directory clean<\/pre>\n<p>I then added remote &#8220;shapes&#8221; to the project, but it already existed locally&#8230; See next step.<\/p>\n<p>user@WINDOWS_PC \/C\/Shapes (master)<br \/>\n$ git remote add shapes http:\/\/www.stonemillkids.com:XX\/username\/Shapes.git<br \/>\nfatal: remote shapes already exists.<\/p>\n<p>Instead I added a new &#8220;Stuff&#8221; project and pointed <em>that<\/em> to the remote server<\/p>\n<pre>user@WINDOWS_PC \/C\/Shapes (master)\n$ git remote add Stuff http:\/\/www.stonemillkids.com:XX\/username\/Shapes.git\n\nuser@WINDOWS_PC \/C\/Shapes (master)\n$ git show\ncommit f2720716a70029b4f00df8b997e63e23503c34cb\nMerge: 199b214 15aa4d4\nAuthor: Greg S &lt;gschallert@gmail.com&gt;\nDate:\u00a0\u00a0 Mon Jul 13 02:29:03 2015 -0400\n\nMerge http:\/\/www.stonemillkids.com:XX\/username\/Shapes\nuser@WINDOWS_PC \/C\/Shapes (master)\n<\/pre>\n<p>I am not sure if the next couple commands are needed, but I wanted to add everything locally to the server<\/p>\n<pre>$ git add .\n\nuser@WINDOWS_PC \/C\/Shapes (master)\n$ git push Stuff\n\nUsername for 'http:\/\/www.stonemillkids.com:XX': username\nPassword for 'http:\/\/username@www.stonemillkids.com:XX':\nCounting objects: 172, done.\nDelta compression using up to 4 threads.\nCompressing objects: 100% (139\/139), done.\nWriting objects: 100% (171\/171), 7.58 MiB | 358.00 KiB\/s, done.\nTotal 171 (delta 9), reused 0 (delta 0)\nTo http:\/\/www.stonemillkids.com:XX\/username\/Shapes.git\n15aa4d4..f272071\u00a0 master -&gt; master\n\nuser@WINDOWS_PC \/C\/Shapes (master)\n$\n<\/pre>\n<p>Going back to the GitLab Server, I checked the project and all of the docs and my project code there.<\/p>\n<p>Now progress real coding can begin.<\/p>\n<p>Update:\u00a0 The &#8220;add .&#8221; command did not add all of the .xml files from the LibGDX project, so I had to reconfigure LibGDX to make it work. Next time I download a new project I will document that.<\/p>\n<h3>Other commands that I might find useful<\/h3>\n<p>In investigating how to do the above, I took notes on other examples that might be useful. They are below:<\/p>\n<h4>Checking into the server<\/h4>\n<pre># setup the remote server that your local branch is pointing to\n$ git remote add Stuff http:\/\/www.stonemillkids.com:XX\/username\/Shapes.git\n#Check the Changes you made to make sure everything good\n$ git status\n#Add all of the changes to the commit\n$ git add .\n#commit the changes locally\n$ git commit -a\n#Push the changes back to the server\n$ git push\n<\/pre>\n<h3>Branching into a new project<\/h3>\n<pre>#Create a Branch \"RC1\"\n$ git checkout -b RC1\nSwitched to a new branch 'RC1'\n#Push the branch to the staging repository\n$ git remote add staging http:\/\/www.stonemillkids.com:XX\/username\/Shapes_Staging.git\n$ git push stage RC1:RC1\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In this post I will be creating a project on GitLab and Syncing my local files with it.\u00a0 Here are links to the previous posts for setting up GitLab and changing the default\u00a0Labels. Background I have a project that I created on GitLab called &#8220;Shapes&#8221;\u00a0 that contains a single\u00a0Readme.txt.\u00a0 I have a folder called Shapes [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":740,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[14],"tags":[42,31],"_links":{"self":[{"href":"http:\/\/www.stonemillkids.com\/index.php\/wp-json\/wp\/v2\/posts\/576"}],"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=576"}],"version-history":[{"count":3,"href":"http:\/\/www.stonemillkids.com\/index.php\/wp-json\/wp\/v2\/posts\/576\/revisions"}],"predecessor-version":[{"id":953,"href":"http:\/\/www.stonemillkids.com\/index.php\/wp-json\/wp\/v2\/posts\/576\/revisions\/953"}],"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=576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.stonemillkids.com\/index.php\/wp-json\/wp\/v2\/categories?post=576"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.stonemillkids.com\/index.php\/wp-json\/wp\/v2\/tags?post=576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}