Last updated: 23 October 2026. Prefer the command line? See my companion guide: Push a Project to GitHub from the Ubuntu Terminal.
Android Studio has GitHub built in, so you can put an app on GitHub without typing a single Git command: log in once, click Share Project on GitHub, and Android Studio creates the repository and pushes for you. This guide walks through that, then the everyday commit → push loop, branches and pull requests, and the files you must keep out of a public Android repository.
Contents
- Before you start
- Connect Android Studio to your GitHub account
- Check the .gitignore first
- Share the project on GitHub
- Commit and push changes
- Branches and pull requests
- Open a GitHub project in Android Studio
- Troubleshooting
1. Before you start
- A GitHub account, free at github.com.
- Android Studio, set up as in my Android Studio installation guide.
- Git installed on your computer. Android Studio uses your system's Git.
- Ubuntu:
sudo apt install git - Windows: install Git for Windows, or let Android Studio download it when it asks.
- macOS: run
git --versionin Terminal and accept the prompt to install the command-line tools.
- Ubuntu:
Check that Android Studio found it: Settings (Ctrl+Alt+S, or Android Studio → Settings on macOS) → Version Control → Git → click Test. It should show a Git version number.
Also set your name and email for commits, once, in a terminal (Android Studio has one built in: View → Tool Windows → Terminal):
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
2. Connect Android Studio to your GitHub account
- Open Settings → Version Control → GitHub.
- Click + → Log In via GitHub…
- Your browser opens. Sign in to GitHub and click Authorize.
- Back in Android Studio, your account appears in the list. Click OK.
This is the easiest way to authenticate: Android Studio stores a token for you, so you never type a password or create a personal access token by hand. (GitHub stopped accepting account passwords for Git in 2021, which is why older tutorials that ask for one fail.)
3. Check the .gitignore first
New projects from Android Studio's templates already include two .gitignore files: one in the project folder and one in app/. Open the project-level one (switch the Project panel from Android to Project view to see it) and make sure it covers at least:
*.iml
.gradle/
/local.properties
/.idea/
.DS_Store
/build
/captures
.externalNativeBuild/
.cxx/
*.jks
*.keystore
google-services.json
Why these matter:
local.propertiescontains the SDK path on your computer, and is often where people put API keys. It must never be committed.*.jks/*.keystoreare your app signing keys. Anyone with the keystore and its password can sign updates as you. Keep them in a safe backup, not in Git.google-services.json(from Firebase) isn't a password, but on a public repository it's best left out; teammates can download their own copy from the Firebase console. On a private repository many teams do commit it.build/and.gradle/are generated files: huge, and rebuilt every time.
Do commit the Gradle wrapper (gradlew, gradlew.bat and gradle/wrapper/) and gradle/libs.versions.toml, so anyone who clones the project builds with the same Gradle and library versions.
4. Share the project on GitHub
With your project open:
- Open the main menu (in the new UI, click the ☰ icon at the top-left) → Git → GitHub → Share Project on GitHub. If Git isn't enabled for the project yet, the same option is under VCS → Share Project on GitHub.
- Enter a Repository name (e.g.
counter-app), tick Private if you don't want it public, and add an optional description. Click Share. - Android Studio shows the files for the first commit. Check the list: you should not see
local.properties,buildfolders or a keystore. If you do, cancel and fix the.gitignore(section 3). - Keep the message "Initial commit" and click Add.
Android Studio creates the repository on GitHub, makes the first commit and pushes it. A notification at the bottom-right links to the new repository; click it to see your code on GitHub.
Trying this with the tap-counter app from Create Your First Android App is a good first run.
5. Commit and push changes
From now on, after you change some code:
- Commit: press
Ctrl+K(Cmd+Kon macOS), or open the Commit tool window on the left. Changed files are listed with checkboxes. Double-click any file to see a side-by-side diff of what changed. - Tick the files to include, write a clear message (e.g. "Add reset button"), and click Commit. Or click Commit and Push… to do both at once.
- Push: press
Ctrl+Shift+K(Cmd+Shift+K), check the commits listed, and click Push. - Pull changes made elsewhere (by a teammate, or by you on another computer):
Ctrl+T(Cmd+T), Update Project.
File colours in the Project panel tell you the state at a glance: green = new and not yet committed, blue = modified, red = not tracked by Git, grey/olive = ignored.
The Git tool window (Alt+9) shows the full history as a graph. Right-click a file in the editor → Git → Show History to see every change to that one file.
6. Branches and pull requests
A branch lets you work on a feature without touching the working version of the app in main.
- Click the branch name in the toolbar at the top (in the new UI) or the status bar at the bottom-right (older versions) → New Branch… Name it after the work, e.g.
feature/dark-mode, and keep Checkout branch ticked. - Commit as usual. When you push, Android Studio pushes the new branch to GitHub.
- Open a pull request: Git → GitHub → Create Pull Request, or open the repository on GitHub, where a yellow banner offers Compare & pull request. Describe what changed and create it.
- Review the changes (or have a teammate review them), then click Merge pull request on GitHub.
- Back in Android Studio, switch to
mainfrom the branch menu and Update Project (Ctrl+T) to get the merged code.
Merge conflicts: if two branches changed the same lines, Android Studio opens a three-panel merge tool when you pull or merge: your version on the left, theirs on the right, and the result in the middle. Click the arrows to accept either side (or edit the middle by hand), then click Apply.
7. Open a GitHub project in Android Studio
To work on an existing repository, or on your own project from another computer:
- From the Welcome screen, click Clone Repository (or File → New → Project from Version Control).
- Choose GitHub on the left to pick from your repositories, or paste any repository URL.
- Choose a folder and click Clone. Android Studio downloads the code, opens it and runs a Gradle sync.
Because local.properties isn't in the repository, Android Studio creates a fresh one pointing at your SDK. If the app uses Firebase and google-services.json isn't committed, download it from the Firebase console into the app/ folder before building.
8. Troubleshooting
| Problem | Fix |
|---|---|
| "Cannot run program git" or Git test fails | Git isn't installed or the path is wrong. Install Git, then set the path in Settings → Version Control → Git (on Ubuntu, /usr/bin/git). |
| Share Project on GitHub is greyed out or missing | Check you're logged in (section 2). If the project already has a Git remote, use Push instead. |
| Push rejected: "Updates were rejected because the remote contains work…" | Someone (or you, on GitHub's website) changed the repository. Update Project (Ctrl+T) first, then push again. |
local.properties or build/ was already committed | Add it to .gitignore, then in the terminal run git rm -r --cached local.properties app/build and commit. If local.properties contained API keys, rotate those keys. |
| Committed a keystore or real API key to a public repo | Treat it as leaked: rotate the key immediately. Removing it in a later commit doesn't remove it from history. |
| Authentication failed after a while | The stored token was revoked or expired. Remove the account in Settings → Version Control → GitHub and log in again. |
| Clone fails to build: "SDK location not found" | Open the project once with File → Sync Project with Gradle Files so Android Studio creates local.properties, or set the SDK path in Settings → Languages & Frameworks → Android SDK. |
Want to understand what Android Studio is doing behind these buttons? The same steps with plain Git commands are in my terminal guide, which also covers SSH keys.
Next: follow the Android developer roadmap and keep each project you build in its own GitHub repository.
.jpg)