Connecting to GitLab repositories on Android Studio - android

I'm trying to connect to a GitLab repository using the I/O preview of Android Studio. Does anyone know how to do this/if it is possible yet?

How to add an Android Studio project to GitLab
This answer shows how to do it using the Android Studio GUI.
1. Create a new project on GitLab
Chose the + button on the menu bar. Add a project name and then click "Create project".
This will give you a new project address. Choose the https version.
It will look something like this:
https://gitlab.com/MyUserName/my-project.git
2. Create a Git repository in Android Studio
In the Android Studio menu go to VCS > Import into Version Control > Create Git Repository...
Select the root directory of your project. (It will be automatically selected if you already have it highlighted in the Project view. Otherwise you will have to browse up to find it.)
3. Add remote
Go to VCS > Git > Remotes.... Then paste in the https address you got from GitLab in step one.
You may need to log in with your GitLab username and password.
4. Add, commit, and push your files
Make sure you have the top level of the project selected. If you are in the Android view you can switch it to the Project view.
Add: Go to VCS > Git > Add.
Commit: After adding, do VCS > Git > Commit Directory. (You will need to write a commit message, something like initial commit.)
Push: Finally, go to VCS > Git > Push.
Finished!
You should be able to view your files in GitLab now.
See also
There is a plugin that would probably streamline the process. Check it out here.

To clone a repo
Open a new project in Android Studio.
Click VCS -> Checkout from version control -> Git
then enter the URL of the repo and your local direcory
To commit
Open the project you want to push in Android Studio.
Click VCS -> Enable version Control -> Git
There does't seem to be a way to add a remote through the GUI. So open Git Bash in the root of the project add 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.
See these pages for details:
http://www.jetbrains.com/idea/webhelp/using-git-integration.html
http://youtrack.jetbrains.com/issue/IDEA-87099

Use CodeStream plugin, easy configuration

Related

Unable to add android project to GitHub account in Android Studio

I tried to add my Android project to my Github account using Android Studio's
VCS -> Import into Version control -> Share project on github
However, I am getting this https://github.com/vkrpro/Musica.
I tried the solution recommended, but I am still not able to create my repositories. After that I deleted my empty repositories, but I am still seeing the commit command on Android Studio. How can I get around this?
Follow these steps:
VCS -> select "Enable Version Control"
Then in the left panel click on Android and select Project
Then right click on the name of the project then from menu select Git -> sekect "Add".
After all the files are added go to VcS -> Select "Commit".
Add a message then select commit and push at bottom of the dialog which has appeared.
A dialog will open where you should define remote and add the link of you directory created in git hub.
Then select "Push" at bottom of the dialog.
you can only import a project from VCS if you have already created it. to do that you first need to create a repository on Github
commit your work then push to the remote Github repository. you can then link your local and remote work using VCS.

How do I connect GitHub Enterprise in Android Studio? [duplicate]

This question already has answers here:
How do you synchronise projects to GitHub with Android Studio?
(13 answers)
Closed 5 years ago.
I have a project in Android Studio. I want to add that project to a GitHub repository using android studio. How can I do that?
Sign up and create a GitHub account in www.github.com.
Download git from https://git-scm.com/downloads and install it in your system.
Open the project in android studio and go to File -> Settings -> Version Control -> Git.
Click on test button to test "path to Git executables". If successful message is shown everything is ok, else navigate to git.exe from where you installed git and test again.
Go to File -> Settings -> Version Control -> GitHub. Enter your email and password used to create GitHub account and click on OK button.
Then go to VCS -> Import into Version Control -> Share Project on GitHub. Enter Repository name, Description and click Share button.
In the next window check all files inorder to add files for initial commit and click OK.
Now the project will be uploaded to the GitHub repository and when uploading is finished we will get a message in android studio showing "Successfully shared project on GitHub". Click on the link provided in that message to go to GitHub repository.
You need to create the project on GitHub first. After that go to the project directory and run in terminal:
git init
git remote add origin https://github.com/xxx/yyy.git
git add .
git commit -m "first commit"
git push -u origin master
If you are using the latest version of Android studio, then you don't need to install additional software for Git other than GIT itself - https://git-scm.com/downloads
Steps
Create an account on Github - https://github.com/join
Install Git
Open your working project in Android studio
GoTo - File -> Settings -> Version Controll -> GitHub
Enter Login and Password which you have created just on Git Account and click on test
Once all credentials are true - it shows Success message Or Invalid Cred.
Now click on VCS in android studio menu bar
Select Import into Version Control -> Share Project on GitHub
The popup dialog that will occur contains all your files with check mark, do ok or commit all
At next time whenever you want to push your project just click on VCS - > Commit Changes -> Commit and Push.
That's it. You can find your project on your GitHub now.
First of all, create a Github account and project in Github. Go to the root folder and follow steps.
The most important thing we forgot here is ignoring the file. Every time we run Gradle or build it creates new files that are changeable from build to build and pc to pc. We do not want all the files from Android Studio to be added to Git. Files like generated code, binary files (executables) should not be added to Git (version control). So please use .gitignore file while uploading projects to Github. It also reduces the size of the project uploaded to the server.
Go to root folder.
git init
Create .gitignore txt file in root folder. Place these content in the file. (this step not required if the file is auto-generated)
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.idea
.DS_Store
/build
/captures
.externalNativeBuild
git add .
git remote add origin https://github.com/username/project.git
git commit - m "My First Commit"
git push -u origin master
Note : As per suggestion from different developers, they always suggest to use git from the command line. It is up to you.

Android Studio Gitlab migration

I am attempting to migrate a local project to a currently existing empty Gitlab project repo. I have added via the git shell the project's remote origin. I have also enabled git as the VCS in my AS project. I have committed changes from my project, via AS, however no files are showing in my Gitlab webclient.
Has anyone experienced this issue before?
So you say you have an empty Gitlab project.
Then you said that you have:
Added remote origin, via shell (git remote add origin https:/ /gitlab.com/user/repo.git, right?)
Enabled git as the VCS in your Android Studio project (VCS -> Enable Version Control Integration, and then selected Git from the Select a version control system to associate with the project root:, right?)
Commited changes to your project, via Android Studio (VCS -> Git -> Commit Directory, right?)
That is all ok, you are only missing a push to the remote, git push -u <remote> from the command line, or VCS -> Git -> Push from Android Studio.
If you are using Gitlab then Android Studio Gitlab Projects plugin will be very useful to you. Check it out from Android Studio in File -> Settings, then Plugins, then Browse Repositories...
tl;dr
Given the steps you have already done, I would say you are only missing a push to the remote, as #Darren said, git push -u <remote>. Now, if you want to manage everything from Android Studio, install Gitlab Projects plugin.

Add an Android Studio / IntelliJ project to a code.google.com project with git

So, I have an Android Studio (IntelliJ) project for an app I'm writing. I'd like to add it to a project I've created on code.google.com. How do I do that without having to clone the repository to a new project directory and then push all my AS project files into it?
I see that I can almost do this with VCS > Checkout from Version Control > Git and specify a Git repository URL, but AS forces me to create a new, empty directory when I do this.
How do I setup Git source control with code.google.com as my remote repository, without having to move my existing project files around in the file system?
OK, so the best solution I've come up with is to create a local git repository, create a code.google.com git project, and then manually connect the local repository to the code.google.com project. Note that this requires git to be installed on your development machine.
Create the app project in Android Studio.
Select the root project folder.
Select VCS > Import into Version Control > Create Git Repository
Select project folder to create a git repository.
Now the project is under source control.
Create a project at code.google.com using git source control.
Go to the Source > Checkout page of the project and get the clone URL.
Open a terminal and navigate to the project directory.
Modify the local git repository to connect the remote repository on code.google.com:
git remote add origin https://my-user-name%40code.google.com/p/my-project-name/
Add files to the repository and commit them using the Android Studio interface or the git command-line interface, e.g.;
git add files-for-source-control.ext
git commit .
Finally, push the commit to the remote server:
git push origin master
#ObAt,
If you find Nothing to push message on Android studio, Try this method
Got to
VCS > Git > Push
and Select the tick box for "Push Current Branch to Alternative branch" and click Push button

How do you synchronise projects to GitHub with Android Studio?

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?
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/
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.
Enable the GIT Integration plugin
File (main menu) >> Settings >> Search for GitHub Integration
Enable Version Control Integration for The Project
VCS (main menu) >> Enable Version Control Integration >> Select GIT
Add project file to Local repository
Right Click on project >> GIT >> Add
Commit Added Files
Open the Version Control windows (Next to terminal window) >> Click commit
button
In the prompt window select "commit and push"
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.
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)
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.
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!
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)
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.)
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.
That's all!
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.
Now you can do it like so (you do not need to go to github or open new directory from git):
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:
Setup Android Studio
Setup the Github plugins in the Android Studio settings
Android Studio settings >> Plugins page
Download the git version control system from this link and setup
https://git-scm.com/
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
Go to Settings >> Version control >> Github you will see login and password for your Github account. Apply the settings.
For updating the project, go in Android Studio top line click
VCS >> enable version control integration >> git
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
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
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.
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
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.

Categories

Resources