Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect existing Android Studio project to existing Github repository

So I am new to Android development and Android Studio.

I used Android Studio to create an Android project, and each time I wanted to commit the code to GitHub, I switched over to the command line and committed/pushed the code from there.

However, I realize now that Android Studio has it's own features for connecting to GitHub. I'd like to use those features.

Since the project already exists, I prefer not to just create a new GitHub repository from Android Studio and delete the old one. I just want to connect the existing GitHub repository with the Android Studio project.

How can I sync these up?

like image 507
johncorser Avatar asked Oct 13 '14 17:10

johncorser


People also ask

How do I add an Android project to an existing GitHub repository?

After making a change, you can commit it by selecting the app folder in the Android view (or the main project folder in whatever view you are using). Then go to VCS > Git > Commit Directory.... Add a commit message and click Commit. Then go to VCS > Git > Push to push your changes to GitHub.


2 Answers

Maybe it is a little bit late, but if it helps to someone here is what I do in command line:

cd <proyect folder> git init git remote add origin <link to repo> git fetch origin git checkout master 

note: if there are commits on the repo it may require you to remove conflicting files

git add --all git commit -m "<message>" git push 
like image 111
Ian Neumann Sánchez Avatar answered Sep 29 '22 03:09

Ian Neumann Sánchez


Connecting existing Android Studio project to existing Github repository

If your local project is newer than the one on GitHub, then you can temporarily move it to another location, import the GitHub version into Android studio, delete these old files, and copy in the new files. Then push the changes back to GitHub. The directions to do all of this are here. This takes some command line work, but after it is set up, you can do any future commits right in Android Studio.

Committing and pushing to GitHub from Android Studio

After making a change, you can commit it by selecting the app folder in the Android view (or the main project folder in whatever view you are using). Then go to VCS > Git > Commit Directory....

enter image description here

Add a commit message and click Commit.

enter image description here

Then go to VCS > Git > Push to push your changes to GitHub.

enter image description here

That's it.

like image 24
Suragch Avatar answered Sep 29 '22 02:09

Suragch