Unable to push Android Studio Project to Github - android

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

Related

Can not push on GIT on Android studio

I register on git web site and create a project named Book.this was repo addresshttps://xxxxxxx#gitlab.com/xxxxxxx/Book.git/
and on android studio I pushed my project to git. for a reason, I deleted this project from git site not android studio.now I create another project with this repo:https://xxxx#gitlab.com/xxxxxx/Thread.git but when I am pushing my project I got this error:
manifest#manifest-System:~/AndroidStudioProjects/Book-ThreadExample$ git push -u origin master
Password for 'https://xxxxxx#gitlab.com':
remote: Not Found
fatal: repository 'https://xxxxxx#gitlab.com/xxxxxx/Book.git/' not found
Actually Book.git has been deleted before .how can I change repo? or solve the problem?
I use this command for add remote but I got another error:
git remote add origin https://xxxxxx#gitlab.com/xxxxx/Thread.git
fatal: remote origin already exists.
I am using git on android studio.
I solved my problem.
The error "remote origin already exists" means what it says: I am trying to add a remote with the same name as one that already exists. I need to either delete it first with git remote rm origin, or use git remote set-url to change the URL of the existing remote.

Pulling A Commit from BitBucket in Android Studio 2.2.2

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.

How to transfer git repo from Bitbucket to Github in Android Studio?

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

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.

Why is GitHub causing me pain?

Ok I'm having this issue. I pushed (fresh repo) my Android app to my repo on Github from Android Studio. I then pulled it from AIDE on my tablet. I received no errors, even after pulling, from Android Studio. However, when I use AIDE I get errors such as invalid pack declaration (it's setup correctly). I change it to how it appears in the path, it works just fine (even tho in Android Studio my original setup was right). After that I get a bunch of errors saying R is an unknown entity. R.Java is present, so that's not it. I added the suggested import and that branches off to more errors.
Edit
The commands I have been using are as follows:
On initial setup:
cd C:\...path here
git init
git add .
git commit -m "First commit"
git remote add origin <urltorepo>
git remote -v
git push origin master
updating:
git add --all
git commit -m "message"
git push origin master
and this is what I've been getting:
warning: LF will be replaced by CRLF in <file>
The file will have its original line endings in your working directory
Fixed by recreating the repo and leaving the "Initialize this repository with a README" check blank

Categories

Resources