Setup Git

This section describes how to setup your Git repository with an empty, “starting” project. This step only has to be done by one person! Once this is complete, other team members can just git clone to get a copy of the repository.

ℹ️

Before you can proceed you should have completed the following:

Creating your Git repo

Step 1. Getting a working copy from GitLab

First, you need to git clone your GitLab repository to your local machine so that you have a working copy.

Open the web page for your GitLab project. Click on the Code button, and copy the URL from Clone with HTTPS.

GitLab

In a terminal, on your computer, cd to the location where you want to keep your source code. git clone the URL.

$ git clone https://git.uwaterloo.ca/cs346/public/mm.git

This would produce a folder named mm that contains the contents of my Git repository.

Step 2. Create an empty project.

You will want to create a project directly in your Git working copy from the previous step.

IntelliJ IDEA and Android Studio both fully support Gradle, and we can create a new project directly in the IDE.

IntelliJ IDEA (Desktop)

From the Splash screen, select New Project. New Project Wizard

In the project wizard, choose New Project and supply the following project parameters.

  • Kotlin as your language (from the list on the left).
  • Name is the name of the folder that will contain your source code. e.g., source.
  • Location is the location of your working copy (from Step 1 above).
  • Gradle for your build system
  • JDK should point to your JDK installation (see toolchain).
  • Gradle DSL should be Kotlin as well.

Click Create to proceed. If successful, IntelliJ IDEA will open into the main window to an empty project.

Empty Project Window

You should be able to click the Run button in the toolbar to execute it.

Android Studio (Android)

From the Splash screen, select New Project.

New Project Wizard

Select Empty Activity and Next. A second screen will prompt you for project parameters.

New Project Wizard

  • Name: Your application name
  • Package name: A unique package name.
  • Save location: Your working copy location.
  • Minimum SDK: API 26 or later.
  • Build configuration language: Kotlin DSL.

Click Finish and your project should be created.

You will need to add an Android Virtual Device for testing:

  • Tools > Device Manager
  • +, Create Virtual Deviceand walk through the wizard to add an emulated device for testing.

Step 3. Add a gitignore file

You should probably add a .gitignore file to the top level of your project, specifying which files to NOT include in your repository. Typically, this would be things such as:

  • Build output locations
  • Temporary files
  • Class files
  • IDE files

Here is an example of a .gitignore file that I use:

$ cat .gitignore
build/
out/
*.class
*.tmp
.DS_Store
.idea

Step 4. Push changes to the repository

Once you have confirmed that your project is working, you can commit and push the changes.

$ git add *
$ git commit -m "Initial commit"
$ git push

Step 5. Share with your team

Your teammates should now be able to git clone the project URL to get a copy of this repository.

Final Word

Git
https://xkcd.com/1597