Software Development

Starting developing in Swift: setting up version control with GitLab

Now that I have received my grade for the second part of the Coursera iOS with Swift specialisation I decided it is time to get started to build my own app. The first thing to do (as a professional developer ;-)) is to configure my versioning control in XCode.

Since I have pretty good experiences with Git I decided to setup a GIT repository to use. Normally I would use GitHub for this but since I want to have a free private repository I decided to use GitLab. In the past I have setup my own server running GitLab CE but for now I stay with the free hosting on the Gitlab.com server. After creating an account and signing in into GitLab.com it is just running the commands as shown on the GitLab site when you create your first project. But before I do that I set up the SSH key on my MacBook first so I can use the SSH protocol with GitLab.

To setup a new SSH key on a Mac perform the following commands in your Terminal.
Go to your home directory:

cd ~/

Generate the SSH key:

ssh-keygen -t rsa

Copy the content of the created key to your clipboard:

cat ~/.ssh/id_rsa.pub | pbcopy

Go to your profile on gitlab.com and choose the menu option ‘SSH Keys’. Click on ‘Add SSH KEY’ and paste the clipboard content in the ‘key’ field. Enter a name for the key and you are ready to use HTTPS for your GitLab interactions.

When that is done I can create my project in GitLab:

screenshot-at-dec-03-20-52-52

Just fill in the details and click ‘Create’. This will take you to the ‘Project’ page showing you the commands you can perform on your Mac to ‘clone’ the project to your local system:

screenshot-at-dec-03-20-56-16

Performing these commands in your Terminal should give you the following result:

screenshot-at-dec-03-21-01-05

If you now refresh the page in GitLab you should see that there has been one commit:

screenshot-at-dec-03-21-02-39

This makes sure the basics of GIT are working. Now it is time to implement the Git Flow as I mentioned in a previous post.

To install the Git Flow just run the command ‘brew install git-flow’. When that is finished just run the command ‘git flow init’ in your project to get started with Git Flow (creating necessary branches etc). To push the created branch to the GitLab sever use ‘git push –all -u’. Here you see how it should look like:

screenshot-at-dec-03-21-09-01

In GitLab we now see two branches for our project:

screenshot-at-dec-03-21-10-49

So now we are able to create a remote project and use that in our Terminal on the Mac. In the next post I will dive into the combination of GitLab, XCode and Git Flow.

Pascal Alma

Pascal is a senior JEE Developer and Architect at 4Synergy in The Netherlands. Pascal has been designing and building J2EE applications since 2001. He is particularly interested in Open Source toolstack (Mule, Spring Framework, JBoss) and technologies like Web Services, SOA and Cloud technologies. Specialties: JEE, SOA, Mule ESB, Maven, Cloud Technology, Amazon AWS.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button