How to clone a android open source project to my desktop - android

Essentially I am trying to clone this android open source project to my desktop.
https://android.googlesource.com/platform/packages/apps/DeskClock/+/android-4.3_r1
I am not sure what exactly to do.
I have tried:
git clone https://android.googlesource.com/platform/packages/apps/DeskClock/+/android-4.3_r1
But I got the error:
fatal: remote error: Git repository not found
So how would I have to create a repository and clone it in there?
I am just completely unsure on how to do this locally in my desktop.

The following works for me :
git clone https://android.googlesource.com/platform/packages/apps/DeskClock/
This would download the entire repository.
Then you can checkout any branch you want.

You will want to clone the base repo:
git clone https://android.googlesource.com/platform/packages/apps/DeskClock/
Dive into the directory it just created:
cd DeskClock/
Then you will need to checkout that tag you want to start from
git checkout tags/android-4.3_r1

First, verify the Git Repository URL you use is correct, as given in the official Git repositories on android
In Android Studio, Go for File > New > Project from Version Control > Git.
Paste the Git Repository URL (Don't include git clone here, only the URL)
Click on Test to verify
This should work, as it did for me. This procedure is simple and straightforward.

Related

Git checkout commit hash in AOSP

I never used repo and I've just recently discovered that AOSP is composed of different git repositories.
My question is: how can I checkout between commits?
For example, let's consider this commit
which involves just one .java file (InstallStart.java)
I go to the folder that contains InstallStart.java, in my case:
/mnt/aosp/Android/packages/apps/PackageInstaller/src/com/android/packageinstaller
git log shows that I'm in git repository... but the checkout fails
git checkout 419c6b327562afc9af3bed5e92741e5bf190ec30
fatal: reference is not a tree: 419c6b327562afc9af3bed5e92741e5bf190ec30

Change bitbucket repository name on local project

Im using Android Studio with bitbucket. I changed the name of a repository and now when I try to push, I get the message Fatal error, repository not found.
How do I update the new repository name on my Android Studio Project to push correctly?
Thanks in advance.
See my example:
Go to terminal,
cd projectFolder
git remote -v (it will show previous git url)
git remote set-url origin https://username#bitbucket.org/username/newName.git
git remote -v (double check, it will show new git url)
git push (do whatever you want.)
See my example:
I simple changed the repository name accessing the config file inside the .git folder of my project. That solved the problem.
Update your git remote, changing the repo url: https://help.github.com/articles/renaming-a-remote/

Cloning a subdirectory of a repository off GitHub using Android Studio

I was wondering whether it is possible to clone a subdirectory of a repository off GitHub using Android Studio? Usually when you clone a repository, you go "Check out project from Version Control" --> GitHub --> then you get something like this
However, for example, I would like to clone this subrepository as I would like to build the project and put it in my emulator. This address is https://github.com/hmkcode/Android/tree/master/android-material-design-appcompat.
I have tried to guess https://github.com/hmkcode/Android.git might have becomehttps://github.com/hmkcode/Android/android-material-design-appcompat.git, but this did not work.
Is it possible to clone this subrepository as I dont want the rest of the repository. I dont want to have to clone the whole thing and try to piece together the sub project.
This is not a "subrepo": it is just a subdirectory, and git reasons at the repo level.
You could use sparse checkout though, but it is not supported directly by Android studio. You would have to prepare your local repo:
mkdir hacker-scripts
cd hacker-scripts
git init .
git config core.sparseCheckout true
echo 'android-material-design-appcompat/' > .git/info/sparse-checkout
git remote add -f origin https://...
git pull origin master

How to put an Android Project on Github?

I was trying to use Android Studio's in built VCS but was getting some error. I recently learned that it can be done using Git also. Can anyone tell me how to do that ?
Try this:
git init (unless you have already done so)
git config user.name "someone"
git config user.email "someone#someplace.com"
git add *
git commit -m "some init msg"
Note that the email you use should be the same as the one associated with your GitHub account.
Alternatively you can use Tools like SourceTree to configure. It is quite easy to configure and perform git operation using sourceTree.
https://www.sourcetreeapp.com/

How to delete a repository and add a new one in Android studio?

I was working with VCS enabled in Android Studio and pushed my code to a repository that I had created in BitBucket. However, now the team I'm working with has created a new repository also on BitBucket and I have to switch my entire project there. So how do I stop VCS in my current project, and push code to a new repoositroy with a new link from scratch?
Also, in the first repository that I was working with only the "java" folder was pushed and not the rest. Now in the new repository I want to be able to commit and push changes made in all other files as well like "res" etc.
U can remove connection from git repository.
step 1 :Open git bash.
step 2 : navigate to the master folder. '
step 3 : $ git remote rm origin
The git remote will now be removed from the repository.
Now u can add new connection by using VCS->Git->+add.
[Remove and add git]
or you can add/edit remote url
VCS -> Git -> Remotes...

Categories

Resources