Can not push on GIT on Android studio - android

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.

Related

Unable to push Android Studio Project to Github

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

How to copy Android Studio project to remote Git (NOT GitHub) server

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.

How do I get started integrating Git with Android Studio?

I've set up a Git server on my LAN (Simple Git Server for Mac). I'm using other machines on the LAN for Android Studio development. What now? On Android Studio's VCS menu, "Integrate Project..." is grayed out.
If I understand, I have to first create a local repository on the workstations, then somehow get my project files into it and get it copied to the server. Can't figure out how to do either. It seems usable if you already have your remote repository set up and populated, but I can't get to square one.
Also: is it recommended to have a separate repository for each project?
If you already have a git repository set up online. First you do git init in the directory that you want to submit to git, then you need to commit the files you want to add by doing git add . for all your files or git add <your file> for a specific file. After that you need to commit the files by doing git commit -m "your message here " and then you do:
git remote add origin <remote repository URL> //get this from git assuming your have already set up the git repo
# Sets the new remote
git remote -v
# Verifies the new remote URL
Push the changes in your local repository to GitHub.
git push -u origin master
# Pushes the changes in your local repository up to the remote repository you specified as the origin
All this info comes from the git documentation here:
https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
And yes, typically you want to have a separate repository for each project. There are exceptions, but personally, I have yet to find a suitable one.

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

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