In this post I will explain how you can get started with Android Studio 2.3.3 from an existing git repository. As git hosting platform, I am using gitlab.com, but it will be the same procedure to follow from any other git hosting (or local) platform.

  1. Go to ‘File – New – Project from Version Control’ and choose Git
  2. The ‘clone repository’ window is shown
    clonerepository
  3. Copy the git repository url from your git server. When you are using SSH, it is of the form: git@gitlab.com:<project name>/<repository name>.git , when you are using HTTPS, it is of the form: https://gitlab.com/<project name>/<repository name>.git . The ‘Directory Name’ is automatically filled in.
  4. Choose the parent directory where you want to store the workspace on your hard drive and click the ‘Clone’-button.
  5. A window will pop up where you have to fill in your git credentials, either the passphrase for your SSH key, or your user name and password to access the remote git repository.
  6. A message is shown asking whether you want to open the project in the existing window or in the new window. If you have no projects open yet, you can choose for opening in a new window.
  7. Now the git repository is cloned on your local machine, the default branch is checked out. In my case, the default branch is the develop-branch.

I have protected the develop-branch from pushing directly to it, so before we make any changes, we will create a feature-branch.

  1. Right-click the project, go to ‘Git – Repository – Branches…’  and choose ‘New Branch’.
  2. Fill in the branch name, f.e. ‘feature/myfirstbranch’ and click the ‘OK’-button.
  3. At the right bottom of the Android Studio window, the branch is shown which is currently your active branch.
    gitfeaturebranch

Now we can make some changes. With the Git context menu we can commit our changes to the local repository (remind you that these changes are not yet present on the server). It is a good habit to push your changes regularly to the remote repository. You will have an extra backup copy of your changes on the remote and if worthwhile, you can already let your intermediate changes to be reviewed by your fellow developers.

Advertisement