So I have an Android Studio project that I have on Bitbucket that I'm having trouble moving to Github. So far I've imported the project to Github using its import feature and changed the origin using "git remote set-url". Now every time I try to push & commit using Android Studio I get the error "fatal: Could not read from repository". Also I don't know if it has anything to do with the problem but I have tried to change the SSH executable from built-in to native.
Edit: To clarify, the problem I'm having is committing and pushing using Android Studio. Everything works fine if I use git commands but when I use the Android Studio interface the "fatal: Could not read from repository" error pops up.
I suggest creating separate remotes rather than changing the URL for origin. For example, you can do
git remote add bitbucket <URL for BitBucket repo>
git remote add github <URL for GitHub Repo>
Now you can pull and push from each remote as you wish. For example
git checkout master
git pull bitbucket master
git push github master
Related
I've recently got introduced to GitHub. I created a Project and shared it on GitHub. Before that, I've already installed git and Git Bash. I am able to commit changes but can't push it from Android Studio. It gives Permission denied error.
I tried pushing from the command line (Git Bash) using
git push origin master
but same error. After searching I found a workaround
git push https://github.com/user/project master
But I am unable to figure out what's wrong because it gets difficult to sync my project properly with Android Studio
Try reseting your remote url and push.
following is the command for changing the remote
git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
I am working on an Android Studio project and I would like to add a getup repository to the current project. I am using a Mac.
I have downloaded the Github repository and unzipped the folder and was able to create a NEW project using the GitHub repository in Android Studio, but I do not know how to either
A) merge the two projects in Android Studio so my initial project can use the new GitHub Repository Project.
or
B) if I did this process incorrectly and I need to add the GitHub repository directly to my initial Project. I just don't know how and I have looked everywhere for the answer. Any assistance would be fantastic.
I found this answer about merging projects, but I do not know where to find my projects "module root"
You may refer to these 2 links, 1 and 2 for elaborations.
First of all, 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
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 already exists that means you already added it. To see your remotes do git remote -v and git remote rm to remove.
You may also refer to here and here for more understanding.
I can't find instructions for how to copy an Android Studio project from my Mac to a remote Git (NOT GitHub) server.
This doesn't seem like it should be hard but I have searched for hours and can't find anything specific.
A step-by-step guide would be wonderful.
The steps below works for any Jetbrains based platforms like Intellij IDEA, Android studio, PHPStorm, etc. It also works for any git platform (including GitHub)
You can use the following steps to push your code to a remote Git repository:
Goto VCS in the menu bar.
select "Enable version control integration."
choose "Git"(not GitHub) and press ok.
Then you can see a Version control tab near android monitor.
Open version control tab, go to local changes, and add all unversioned files to VCS. (Either right click on unversioned files and click add all, or click browse, select all, and click plus sign to add all to VCS)
Commit changes (Ctrl+K)
Push changes. (Ctrl+Shift+K)
define remote URL
enter username and password.
click on push.
To copy android studio project to a remote repo, you just need to follow below few steps (for your situation):
If the android project already managed in a local git repo
In Android studio Terminal windows, use below commands:
git remote add upstream <URL for the remote repo> -f
git push upstream master
If the android project is not manage in git repo for now, you can use below steps:
In the root directory of your project, execute the following commands,
git init
git remote add origin <URL for the remote repo> -f
touch .gitignore
#Add the (pattern of) files you do not want to traced by git, as https://github.com/github/gitignore/blob/master/Android.gitignore
git add .
git commit -m 'add .gitignore'
git push origin master
Note: If the remote git repo is not empty, you can clone the remote repo locally and then copy your project in it. Then commit and push.
I recently upgraded to Android Studio 2.2.2. I have several commits in BitBucket, but I want to pull a specific commit into a new Android Studio project.
I understand there is a BitBucket plugin, however I do not see any way to install the plugin in Android Studio 2.2.2. I also know that there are 2 methods of cloning in Git: SSH and HTTPS. Not sure which one to use or what the best method of pulling a specific commit would be. Any help would be appreciated!
I can't help you with Android Studio and Bitbucket plugin, but the following information may be useful for you.
SSH or HTTPS. I recommend to use SSH method, in this case you should never enter your password for connect with Bitbucket server. See https://stackoverflow.com/a/40632487/637589
After you've cloned the repository you have master as a current branch. If you want just review all files in specific commit use this command line:
git checkout <your-commit-SHA1>
If want to work (change, commit and so on) basing on this commit - you need to create a new branch:
git checkout <your-commit-SHA1> -b <name-of-new-branch>
I believe you can do the same things using any git plugin to Android Studio
There is nothing special about BitBucket. It's a regular git repository. I don't think you need a plugin.
First, setup your project with git (there are many tutorials on the internet). The way I do it:
Create new repository on BitBucket
open command line and go to the path where you want your new project
type git clone {git url} (you can find it in BitBucket under Overview: git#bitbucket.org:../...git)
open this newly created folder in Android Studio
If you want to checkout a specific commit you can do it in the command line:
git checkout <commit-SHA1>
Or you can do it in Android Studio. Click on the Version Control and you'll see all the commits:
Right-click on your specific commit and select Checkout revision.
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.