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.
- Go to ‘File – New – Project from Version Control’ and choose Git
- The ‘clone repository’ window is shown
- Copy the git repository url from your git server. When you are using SSH, it is of the form: email@example.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.
- Choose the parent directory where you want to store the workspace on your hard drive and click the ‘Clone’-button.
- 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.
- 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.
- 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.
- Right-click the project, go to ‘Git – Repository – Branches…’ and choose ‘New Branch’.
- Fill in the branch name, f.e. ‘feature/myfirstbranch’ and click the ‘OK’-button.
- At the right bottom of the Android Studio window, the branch is shown which is currently your active branch.
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.