Post

How to push a project from Android Studio to GitHub

Introduction

Before pushing your code to GitHub, ensure that you have git installed and SSH keys set up. You can check if git is installed by running git --version in the terminal. Git Version

Steps

Configure Git in Android Studio as follows:

This setup is for Linux. The steps may vary slightly for other operating systems. You only have to do this initial setup once.

  1. Open Android Studio.
  2. Go to File > Settings > Version Control > Git.
  3. Set the path to the Git executable. Path to Git executable for Linux is usually /usr/lib/git-core/git. Path to Git Settings
  4. Click Test to verify the path.
  5. Click Apply and then OK.

Create a repository on GitHub:

  1. Create a new repository on GitHub. Private or public, it’s up to you.
  2. Copy the repository URL. It should look like git@github.com:username/repo-name.git.

Push your project to GitHub:

  1. Open your project in Android Studio.
  2. Go to VCS > Enable Version Control Integration.VCSEnable Version Control
  3. Select Git from the dropdown and click OK.
  4. This will initialize a local Git repository in your project. In plain english, ALL OF YOUR FILES WILL TURN RED 😨
  5. On the far top left corner, click on the arrow beside android and select Project.From Android to Project
  6. Right-click on your project folder and select Git > Add. All files should turn green.
  7. Right-click on your project folder again and select Git > Commit Directory.
  8. In the Commit Changes dialog, enter a commit message and click Commit.Commit Window
  9. On the top toolbar, click on the Git icon and select Repository > Push.Git Push
  10. In the window that pops up, click Define remote and paste the repository URL you copied earlier.Define Remote
  11. Click OK and then Push.

Verify on GitHub:

  1. Go to your GitHub repository and refresh the page.
  2. You should see your project files there.
  3. Congratulations! You have successfully pushed your project to GitHub.

If you encounter any issues, feel free to ask for help.

This post is licensed under CC BY 4.0 by the author.