219

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?

0

13 Answers 13

274

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/

8
  • 4
    When i do VCS -> Commit changes i get No changes detected
    – Humain
    Commented Sep 22, 2014 at 14:15
  • 2
    If the file names in the project window are red that means they aren't being tracked. Right click the file then Git -> Add. Now changes in that file should be detected.
    – jsc0
    Commented Sep 24, 2014 at 12:46
  • 1
    Can I push the same project to 2 github repo? I was not able to. Commented Feb 5, 2015 at 5:54
  • 1
    I know of one way to add the remote through the GUI. If you do a push and you haven't set up credentials and the address for remote, then it will prompt you. You will see master -> Define remote and the "Define remote" part will appear as a link. Click on it and the rest will be self explanatory if you have used Git before. Commented Apr 23, 2015 at 3:17
  • 2
    Great explanations. This video could also be helpful: youtube.com/watch?v=Ldmc757EXaE
    – Sam003
    Commented Jun 2, 2015 at 19:26
66

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

2
  • how can we do this for bitbucket . Is there a way like Github.?? Commented Mar 19, 2018 at 9:26
  • @Nepster you should be able to connect with a bitbucket repo. if you add the your bitbucket repo url at the step 5 in the answer. Also if you need a dedicate plugin please try bitbucket.org/atlassian/jetbrains-bitbucket-connector, but unfortunately it seems the plugin is not supported or updated according to JetBrains.
    – Deshan
    Commented Mar 24, 2018 at 13:34
39

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.

4
  • When I try to do that, I get an error message saying, "Cannot run program "git.exe":CreateProcess error=2,The system cannot find the file specified." Commented Oct 29, 2016 at 16:07
  • showing empty gist error and github repository opened
    – Harsha
    Commented Dec 26, 2016 at 5:33
  • 1
    If you get the error above download latest git from git-scm.com/download/win and set the path to where you downloaded git.exe in Android Studio: File->Settings->Version Control->git "Path to Git executable" ; I had this issue hopefully will help others as well.
    – Sai
    Commented Oct 18, 2017 at 3:09
  • What about bitbucket . HOw to share project on Bitbucket ?? Commented Mar 19, 2018 at 9:27
14

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!

1
  • In Android Studio 0.8.2 I found it via Alt+BackQuote or under VCS -> VCS Operations Popup. In this version of Android Studio I don't see Git under the VCS menu. If there's a plug-in or something I should have please let me know. Commented Jul 13, 2014 at 22:15
11

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)

0
6

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!

0
5

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.

4

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

1

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
  5. Go to Settings >> Version control >> Github you will see login and password for your Github account. Apply the settings.
  6. For updating the project, go in Android Studio top line click VCS >> enable version control integration >> git
  7. 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

1

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
0

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.

0

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
0

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.