Git & GitHub Help/How-To
With Android Studio, you don't need to use the terminal to contribute to an Android project on GitHub. It has native integration with git and GitHub to allow most actions via the Android Studio UI. Below gives an overview of some of these actions!
If your partner has already created a repo and added files, to get on the same repo, you must clone it! (You do not have to create another repo yourself!) If the repo is private, you must be added as a collaborator first (instructions here).
When you clone a repository, you copy the repository from GitHub.com to your local machine. Cloning a repository pulls down a full copy of all the repository data that GitHub.com has at that point in time, including all versions of every file and folder for the project.
When you open Android Studio, it offers the option to open a project from version control. That's the option we'll use (you can also create a new Android Studio project from version control)
After selecting that option, you can type the URL of the repository, press "Clone", and select a folder. After that, Android Studio will do all the work and open the project ready to go.
Make sure you choose the correct account to clone from!
Creating repositories in Android Studio is pain-free (hopefully). If you're working with multiple people, only one person needs to create the repository!
First we have to add Git managing to our current Android Studio project
Go to: VCS -> Create Git Repository
Your files will turn red, don't worry!
Now, we have to create the repository on GitHub and share our files there!
Go to: Git -> GitHub -> Share Project on GitHub
You can then add your files to your newly created GitHub repository!
If your repository is private, you should add your collaborators to your repository so they have access too (which you can now do with your newly created repo). The instructions for that are here. Only the creator of the repository can add collaborators!
Initially, the default branch will be selected most likely master. Let's create a branch for our change based on the master branch! It's bad practice to make changes directly onto our master branch so we can utilize branches to create developmental spaces at the current state of the master without affecting the master branch!
To do that, click where it says "Git: [default branch]", select the master branch, click "New Branch from Selected", and choose a name for your branch.
Once you've actually made some changes to your new branch you have to commit them and push them online!
Now, we can commit our change. To do this, either press CMD+K (or CTRL+K on Windows) to bring up the commit panel!
Review your changes in the screen provided, write a descriptive commit message, select commit and push on the bottom. That will take you to the screen where you'll choose which repository the branch will be uploaded. If you're a maintainer of the origin remote, you can press "Push" and skip to "Creating the pull request".
Now, go to your repository page on GitHub, and you'll see a prompt to open a Pull Request with your newly pushed branch.
When you press that, it will take you to a Pull Request composer.
The Pull Request (PR for short) is the method by which — specifically using Git and GitHub — you can loop interested parties into reviewing and then approving your change, then merging it into some branch (presumably the trunk). This is where you explain the “whats” and “whys” of your code. Feel free to add your partners as reviewers for your code!
Once your PR has been reviewed and is "ready", it can then be merged into your master branch!
With new changes being pushed from your PR into your master branch (from either yourself or your partner), your local files in Android studio are out of date! You can update your files by "pulling" the changes from your repository online into your local repository!
In the top right of your project there's a small toolbar for Git. The blue check mark will update your project!
The buttons to the right commit and push respectively!