How do you synchronise projects to GitHub with Android Studio?

AndroidGithubIntellij IdeaAndroid Studio

Android Problem Overview


I am trying to synchronise a project that I have on in my Android Studio folder to GitHub, but I am not fully sure what to do other than adding my credentials in the options menu. Could someone give me a quick guide, please?

Android Solutions


Solution 1 - Android

Open the project you want to push in Android Studio.

Click VCS -> Enable version Control Integration -> Git

There doesn't seem to be a way to add a remote through the GUI. So open Git Bash in the root of the project and do git remote add <remote_name> <remote_url>

Now when you do VCS -> Commit changes -> Commit & Push you should see your remote and everything should work through the GUI.


If you are getting the error: fatal: remote <remote_name> already exists that means you already added it. To see your remotes do git remote -v and git remote rm <remote_name> to remove.


See these pages for details:

http://www.jetbrains.com/idea/webhelp/using-git-integration.html

http://gitref.org/remotes/

Solution 2 - Android

Following method is a generic way of pushing an Android Studio project to a GIT based repository solely using GUI.This has been tested with a GIT repository hosted in Visual Studio Online and should virtually work with GitHub or any other GIT based version control provider.

Note: If you are using GitHub 'Share on GitHub' is the easiest option as stated in other answers.

  1. Enable the GIT Integration plugin

    File (main menu) >> Settings >> Search for GitHub Integration enter image description here


  1. Enable Version Control Integration for The Project

VCS (main menu) >> Enable Version Control Integration >> Select GIT enter image description here


  1. Add project file to Local repository

    Right Click on project >> GIT >> Add enter image description here


  1. Commit Added Files

    Open the Version Control windows (Next to terminal window) >> Click commit button

    enter image description here

    In the prompt window select "commit and push"

    enter image description here


  1. Defining Remote

    After analyzing code android studio will prompt to review or commit code when committed will be prompt to define the remote repository.There you can add the url to GIT repository. enter image description here

    Then enter the credentials for the repository and click 'Ok'.(Visual Studio online Users need to enable "alternate authentication credentials" as mentioned here to login to repository)

    enter image description here

Solution 3 - Android

On Android Studio 1.0.2 you only need to go VCS-> Import into Version control -> Share Project on GitHub.

Pop up will appear asking for the repo name.

Solution 4 - Android

In the version of Android Studio I have (0.3.2), it was as easy as using the menu.

> VCS Menu > Git > Share on GitHub.

It will then ask you for your credentials, and then a name for your new repo, and that's it!

Solution 5 - Android

This isn't specific to Android Studio, but a generic behaviour with Intellij's IDEA.

Go to: Preferences > Version Control > GitHub

Also note that you don't need the github integration: the standard git functions should be enough (VCS > Git, Tool Windows > Changes)

Solution 6 - Android

Android Studio 3.0

I love how easy this is in Android Studio.

1. Enter your GitHub login info

In Android Studio go to File > Settings > Version Control > GitHub. Then enter your GitHub username and password. (You only have to do this step once. For future projects you can skip it.)

enter image description here

2. Share your project

With your Android Studio project open, go to VCS > Import into Version Control > Share Project on GitHub.

Then click Share and OK.

enter image description here

That's all!

Solution 7 - Android

For Android Studio 0.8.9: VCS --> Import into version contraol --> Share project on Github. It doesn't give you option to share in a specific repository or at least I couldn't find (my limitation!).

You can add your github info here: File --> Settings --> Version COntraol --> Github.

Solution 8 - Android

Now you can do it like so (you do not need to go to github or open new directory from git):

enter image description here

Solution 9 - Android

First time I have added a video link for solving your problem but I learned it was a bad idea. This time I'll explain it briefly.

Android studio is compatible with github but you need adjust something:

  1. Setup Android Studio

  2. Setup the Github plugins in the Android Studio settings

    • Android Studio settings >> Plugins page enter image description here
  3. Download the git version control system from this link and setup https://git-scm.com/

  4. After the installation, open Android Studio settings page and select the git.exe

  • settings >> version control >> git
  • Usually the path to git.exe is program files >> git >> bin >> git.exe
  1. Go to Settings >> Version control >> Github you will see login and password for your Github account. Apply the settings.
  2. For updating the project, go in Android Studio top line click VCS >> enable version control integration >> git
  3. One more time VCS >> import into version control >> share project on Github and enter your master password.

Now you can use VCS update buttons for updating your project to Github

Solution 10 - Android

In Android Studio 0.8.2 , you have the same option (ie Share on GitHub). If you want to find it, you can use ctrl+shift+a and enter github in the input text.

Solution 11 - Android

For existing project end existing repository with files:

git init
git remote add origin <.git>
git checkout -b master
git branch --set-upstream-to=origin/master master
git pull --allow-unrelated-histories

Solution 12 - Android

> Github with android studio

/*For New - Run these command in terminal*/
echo "# Your Repository" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/username/repository.git
git push -u origin master

/*For Exist - Run these command in terminal*/
git remote add origin https://github.com/username/repository.git
git push -u origin master
//git push -f origin master
//git push origin master --force

/*For Update - Run these command in terminal*/
git add .
git commit -m "your message"
git push

Solution 13 - Android

This is how I got mine working using Android Studio UI:

Delete .git folder from your project folder. Delete .git folder from all your project subfolders.

Open project in Android Studio.

Settings, Version Control, remove all the roots

Go to VCS, Import into VC, Create git repository

Select the directory

Make sure your folder is the only root in Settings, Version Control

Go to VCS, Import into VC, Share project on Github

Mark as private if wanted.

Select all the files for initial commit, including app folder

Add files, select all in your project folder and app folder.

VCS > Commit -> to commit the files.

VCS > Git > Push -> to push the files.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDzinicView Question on Stackoverflow
Solution 1 - Androidjsc0View Answer on Stackoverflow
Solution 2 - AndroidDeshanView Answer on Stackoverflow
Solution 3 - AndroidzekeView Answer on Stackoverflow
Solution 4 - AndroidLe3woodView Answer on Stackoverflow
Solution 5 - AndroidetienneView Answer on Stackoverflow
Solution 6 - AndroidSuragchView Answer on Stackoverflow
Solution 7 - AndroidAbu ShumonView Answer on Stackoverflow
Solution 8 - AndroidsiviView Answer on Stackoverflow
Solution 9 - AndroidMucahit KenanView Answer on Stackoverflow
Solution 10 - AndroidThreadView Answer on Stackoverflow
Solution 11 - AndroidMateusz KaflowskiView Answer on Stackoverflow
Solution 12 - AndroidAftab AlamView Answer on Stackoverflow
Solution 13 - Androidlive-loveView Answer on Stackoverflow