I use GitHub in Android Studio, I pull a project from GitHub using URL.
At present, I hope to copy the URL of the GitHub project, but I find the URL can not be copied, you can see Image 1.
How can I get the GitHub URL of the project in Android Studio?
Image 1
You can view the remote links in Android Studio as:
In menu, click VCS => git => remotes
Then you can copy(select any remote url + cmd/ctrl + C), add, delete or edit the remote url:
Alternately, you can get the complete details in terminal using
• git remote show origin
It Android Studio, in the bottom bar where the LogCat is, there's another window named Terminal open it, and the type:
git config --get remote.origin.url
The URL will be displayed and you can copy it from there
I think this is the easier way (less typing):
$ git remote -v
You can add to your profile with: alias s='git remote -v && git status'
Related
I've started working with Android Studio and I found a problem when trying to connect to Github. I've tried restarting Android Studio and even creating a new project, but I am not able to login.
I installed Git and it´s working in the local repository.
The problems are:
Incorrect credentials
Request response: 401 unauthorized
You can use the Project from Version Control, it has git.
What I did was I logged in through a token, it also tells you what needs to be added to the token and that worked for me.
You can create the token here:
https://github.com/settings/tokens
Note: I found this solution on: Can't log in to GitHub on Android Studio.
Such solution worked perfect for me!
On GitHub:
Log in -> Click on your avatar in the top right hand corner
Choose Settings -> Developer settings -> Personal access tokens
Click on the "Generate new token" button
Add a note if you want (in my case was mandatory), like "Android Studio"
Select repo(all), read:org (under admin:org), gist
Click on the "Generate token" button
Copy the token
On Android Studio:
Go to File -> Settings -> Version Control -> GitHub
Add an account (plus button on the right side, choose "log in with token")
Click the "Use Token" hyperlink, like in your screenshot
Paste your token, click login, click ok
I got the issue solved by generating a token from https://github.com/settings/tokens and using it to add account option on Android Studio>File>settings>GitHub
you can install git in your operation system and use command for add your android project to github repository.
1- you should install git bash
2- open git bash in your project directory and initial it as a git repository
git init -b main
3- add your project to the local repository
git add .
4- commit your file to the local git repository
git commit -m "First commit"
5- Create a branch, usually called a 'main' or 'master'
git branch -M main
6- define remote git url
git remote add origin remote repository URL
7- finally, you should push all your project into remote git repository
git push -u origin main
Couple of issues can be there to block you from accessing your github repo and throwing 403 error. Hence please go step by step.
Step-1 : Local git is corrupted or not working
git branch -r [If it gives result you are good]
git ls-remote --heads <remot_git_location>
if one of the above is working then your local git is good. If not use
git config --global --unset credential.helper
Step-2 : From your IDE (IntelliJ or Android Studio etc) see git is configured and test it.
Go to Default Settings-->GitHub and Your host should be "https://github.com"
Get your Github personal token. Login to your github account from browser. Settings -> Developer settings -> Personal access tokens.
o Select all “repo”, gist and “read.org” in your scope.
o Create the token
Last step: If still not working, Go to VCS--> GIT --> Remotes --> Change the repo to include token explicitly
https://user_name:<your_TOKEN>#github.com/reponame.git
Paste the token in your IDE and test the connection.
If your problem still persists then check if there is network issue.
Updating to AndroidStudio 4.1.1 allowed me to access with my credentials without having to generate a token.
You have to check all required settings (see image GitHub settings required) at your GitHub account at https://github.com/settings/tokens/, and then you have to update the token (You must regenerate your token if you havent copied yet).... Then you can insert your credentials again in Android Studio and... ¡ready!
I have created repository on my GitHub account and successfully added my android studio project to it last week
I could push and pull with no issue but suddenly GitHub doesn't allow me to clone repository URL from android studio or push or pull the project
After hours of investigation I understood that a public key for SSH is needed
I even created that with git command lines and copied it in GitHub settings, but still have same problem.
1- Why I could work with GitHub but now I can't?
2- How to disable SSH from GitHub repository and using only HTTPS for push and fetch?
3- What is the best solution for this? I just want to push / pull the project.
** New explanation **
I did what #VonC said but no change on URLs :
By the way, I use Android Studio
I did push then get this error :
Finally I found the solution by #VonC help
I created ssh public key in my bin terminal in windows 10.
I added that to my github acount/settings.
( just need to be checked) I get authorized in bin terminal (windows):
MINGW64 /bin $ ssh -T git#github.com
Enter passphrase for key : XXX
... Hi tahadev! You've successfully
authenticated
Then
I did this command in Android Studio terminal :
"git remote set-url origin git#github.com:tahadev/Native_Form_Android.git"
Then
(By the way it is weird why it shows HTTPS url when setting for SSH)
"git remote -v"
origin https://github.com/tahadev/Native_Form_Android.git (fetch)
origin https://github.com/tahadev/Native_Form_Android.git (push)
Then I did PULL first then PUSH, in some back/force :) I finally could be able to reach my code in git from Android Studio
Thx #VonC
Android Studio terminal code and bin terminal
I find strange that the first push error message mentions "Git#github.com": only git#github.com could work, not Git.
But in any case, if you want to experiment with HTTPS without changing anything, type anywhere:
git config --global url."https://github.com/".insteadOf git#github.com:
Then check again how a push works in VSCode.
To revert:
git config --global --unset-all url.https://github.com/.insteadof
That insteadOf setting would not change a git remote -v output (still SSH there)
If would simply ensure to use an HTTPS URL when doing a git push.
I have installed the VS Code by following the VS CODE site.
Now I want to use it to open my git repository to edit files.
Installation is completed on Linux.
Clone your repo first to a local directory.
Open VSCode.
Select 'File-->Open Folder' and select the cloned folder.
The files will be shown in the side bar.
I am trying to configure Android Studio to work with my team repo on Bitbucket. What I would like to do in the first place is to push my local project onto my team's repo.
I have already installed the Bitbucket plugin but don't really know where to go from here. When I try to commit the changes, all I get is "No changes detected".
Without Using Any Plug-in
First from VCS menu of android studio select Enable Version Control Integration, it will ask you for selecting versioning tool, select git from the drop down.
Create new repository in the BitBucket account for the project, selecting git as the repository type.
Now from the terminal window at the bottom of android studio, type: git add -A
This will add the files to git for committing.
To commit with a message type git commit -m "First Commit" in the terminal. Here, First Commit is just a message i used for demonstration.
From Bitbucket, in the newly created repo, select I have an Existing Project from below. It will give you two command line commands. Use Them consecutively. These will add the local repo to the bitbucket. First one: git remote add origin https://example#bitbucket.org/example/test.git
Second one:
git push -u origin master
Add again git add -A
Then Commit git commit -m "Second Commit"
Push for the last time git push origin master
You can check that the branch is up-to-date by writting git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
Done .
My Android Studio version was 2.3.3 & git version 2.13.0.windows.1
So I am assuming you have a local project and you need to import it into your Repository in BitBucket. Since you already have the BitBucket plugin installed, follow the below steps:
Goto VCS Menu > Import into version control > Share Project
You will have to give your credentials when prompted.
On the next dialogue, give a name and a description to your project and then click OK
Now you have got your project imported to BitBucket. Now to checkout a project from BitBucket:
VCS > Checkout from version control > BitBucket
Select the project you want to checkout
After you have added the project to BitBucket, you will see a menu called Git in you VCS menu, which has all the options of Git.
Now depending on the version of android studio and the BitBucket plugin you are using, you are likely to get some errors while doing these. I did these using Android Studio 0.8.2 and Bitbucket plugin version 1.2.2.
Also make sure in the Android Studio Preferences > Version control, the directory is set to <Project> and the VCS to Git. Unless you are using Mercurial or anything it is advisable to remove any VCS other than Git from there. If all these are right everything should be working well.
There is a bug in the third-party Bitbucket plug-in which is preventing it from working, although you can still configure Android Studio to work with Version Control.
Create a repository on Bitbucket.
Clone it via VCS > Checkout from Version Control > Mercurial or Version Control > Git.
Use the HTTPS or SSH URL shown in the "Clone" tab for the repository on Bitbucket as the Repository URL.
Copy and paste your local project into your cloned repository.
You may now use Android Studio to work the repository.
Android Studio -> VCS -> Enable version control
Right-click on your root directory -> select git -> Add
Then click on ctrl+K
Write your commit msg
Click on Define Remote
Paste your git repository url.
PUSH
//Easy tutorial on android studio with bitbucket (linux)
create bitbucket repository "testp"
create a folder "gtest" on your local machine
go to this local folder("gtest") with cd command
now clone git repository "tesp" with clone command
this repo "testp" folder must come inside that "gtest" folder now
open android studio and create a project "MyApplication" by selecting the project location folder "testp"
now open terminal and go to path with cd command upto that tesp folder (you can use terminal inside android studio)
now hit ls command and it should show your project dir "MyApplication"
on your terminal type command "git add MyApplication/".
10.now enable vcs by clicking menu on vcs and enable vcs ...
once the vcs is set or enable then select your appliation "MyApplication" project >> right click >> git >> commit directory >> may write comment "initial commit" and hit "push and commit" button.
see event log for more detail
check out the repo it should be there.
if you have to pull this project only then goto "MyApplication" project >> right click >> git>> repository>> pull
Note: here "testp" , "gtest" and "MyApplication" are only example
If you have already android project then
select menu(vcs) check out from version control
click clone and copy repository from bitbucket and paste it on dialog given by selecting menu1
On the second menu provide specific location where you want to clone
After clone is success it will ask something like create project, anyways click yes.
Now project is created
6.right click on the project and clik new> add module > import project(this is where you import the already existed android project)
7.After every thing is done, build.gradle may have build problem ,if occur paste following code :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
now cd up to your bitbucket clone folder using android terminal
now add everything inside this folder using git command "git add file1 file2 file3"
And lastly right click on your project and goto git>commit directory> commit and push and its done
11.You have your code push and commit on bitbucket : check it out
done
// clone on other computer
clone the bitbucket project using vcs option
and load project(not import) after it get clone
if this not work:
vcs clone to desired directory((click no ,if it ask something like yo have check out an android studio project..Would you like to open it)) and import the project using exact same location of clone directory(use gradle wrapper if asked : it may download so wait) and lastly enable vcs for push and commit.
Here is what you can try.
Android Studio -> VCS -> Enable version control
Android Studio -> Changes
Review all files and commit. At this stage you might have to add your files
to VCS manually.
Now you can share it on Bitbucket by
VCS-> Share it on Bitbucket
Note:- For bitbucket you will have to install "following Bitbucket plugin"
for Android Studio. http://plugins.jetbrains.com/plugin/6207?pr=androidstudio
You need to add the files to your local repository first.
Go to menu VCS -> Show Changes View.
Add all the files.
Then got to menu VCS -> Import into Version Control -> Share project.
You will be ask to enter the bitbucket origin URL. And that's it.
So basically I have an Android Studio project on my local computer and I need to add it into my BitBucket repository I created online. I just can't get it right with Android Studio. I can't upload files from Android Studio project to my BitBucket repository.
How can I do such a thing?
Here is how I did it without plugins:
Create the repository on your Bitbucket account
Create your project in Android Studio
In Android Studio, Go to VCS
Choose 'Enable version control'
Choose Git and press OK
Right click on your project, choose Git then click Add
Open Terminal in Android Studio
Go to your Bitbucket repository Overview
Click on 'I have an existing Project'
Copy the 'git remote add origin ... etc.' line to your terminal and press enter
Click on 'Commit Changes', write your comment then press Commit and push
Also add the 'git push -u origin master' in the terminal at part 10 of above
In the Android studio, go to VCS-> 'Enable version control'.
From dropdown menu select Git, then click OK.
Right click on your Project view in the Android Studio:
go to Git -> Add.
(All the files in the project should change the color, turned green probably)
Open Terminal in the Android studio.
From your empty repo in the Bitbucket page, copy from the paragraph "Step 2: Connect your existing repository to Bitbucket" the line :
git remote add origin https://<user>#bitbucket.org/<path>.git, then Enter.
Now type:
git commit -m "initial commit" (to commit all the files from the Project), then Enter.
Now type:
git push -u origin master (to push all the commited files to the master- or the other branch, just change "master" to other branch).
That's it. Your project is versioned and placed in your Bitbucket repo.
Heres is what i did without plugins
Already have a project in Android Studio
1- Create the repository on your Bitbucket account
2- In Android Studio, Go to VCS
3- Choose 'Enable version control'
4- Choose Git and press OK
5- Right click on your project, choose Git then click Add
6- Go to VCS -> Commit Changes
7- Uncheck 'Perform Code Analysis'
8- Press Commit and Push in the Commit button
9- A new window will open, on the left press the DEFINE REMOTE link
10- Go to your Bitbucket repository Overview
11- Click on 'I have an existing Project'
12- Copy the link from bitbucket to the URL tab in the Define Remote Window ,e.g. 'git#bitbucket.org:username/project.git' without the 'git remote add origin...' (maybe it will ask you for a password of your bitbucket account), press Ok
13 Press Push, and it's done
If you want to use Android studio without the use of console/terminal. Use below steps to create a new project in Bitbucket.
Go to VCS in Android Studio
Choose 'Enable version control'
Choose Git and press OK
Right click on your project, choose Git then click Add
Create the repository on your Bitbucket account
Go to your repository in Bitbucket, Copy the https url
Go to Android studio project -> Git -> Repository -> Remotes
Add a new entry with value of https link received from step 6
Android studio -> your project -> Git -> Commit Directory -> Commit & Push
Make sure you define your .ignore file to avoid unnecessary items being copied to bitbucket
From Android Studio, go the the VCS menu on the menu bar and select Import into Version Control, select which VCS you want to use ie: Create GIT repository.
Easiest way is to clone your empty repo with standard "git clone git#bitbucket.org:projectNameAndLocation.git". So let's clone it to the location, as example, user/newAndroidProject.
Create an emtpy Android project from Android studio (let's call it just AProject), in case you don't have one.
Now copy all the files from your new Android project root directory(everything from AProject folder) or just copy all the files from your existing project root directory into the location where your empty repo directory is (into the newAndroidProject folder as example).
So everything from AProject>, goes in the newAndroidProject>.
All the files will be automatically added under the git, inside this repo folder. You can open then for example in the SourceTree your "newAndroidProject" and you will see all the files there and then just push everything to the origin (after you edit your .gitignore file of course).
The BitBucket plugin didn't work with me. However I was able to clone the repository by coping the https url and pasting it in Android Studio then enter the username and password and it should be able to clone it.