Need to reset android AOSP code to Lollipop - android

I have downloaded the current master of Android AOSP which is Android 6.0 source code.
Is there a way available using repo to set the master to Android 5.1 so that all git repositories are set accordingly?
Note: I wish to do this without downloading again.

Quoting from source.android.com:
To check out a branch other than "master", specify it with -b. For a
list of branches, see Source Code Tags and Builds.
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
Edit
Note: I wish to do this without downloading again.
You can try with:
repo init -b <manifest-branch>
repo sync -j8
Edit 2
I want to know if there is way to do it without downloading. The sync
would download from google servers.
The documentation is really clear about the sync command:
Downloads new changes and updates the working files in your local
environment. If you run repo sync without any arguments, it will
synchronize the files for all the projects.
When you run repo sync, this is what happens:
If the project has never been synchronized, then repo sync is equivalent to git clone. All branches in the remote repository are
copied to the local project directory.
If the project has already been synchronized once, then repo sync is equivalent to:
git remote update
git rebase origin/<BRANCH>
where is the currently checked-out branch in the local
project directory. If the local branch is not tracking a branch in the
remote repository, then no synchronization will occur for the project.
If the git rebase operation results in merge conflicts, you will need to use the normal Git commands (for example, git rebase
--continue) to resolve the conflicts.
Since you already synchronized the project once the sync command is equivalent to a rebase.

Related

How to run a specific version of the app from Git via Android Studio?

I use git as my VCS and commit my code every few days. However, a bug has crept in and I need to check if the previously committed versions of the app had that bug too.
How do I keep switching the current codebase to different git versions without losing the local changes that I have not committed? Is there a way in Android Studio to directly build and test a specific version from the git?
Some may suggest git stash and git stash pop/apply.
git stash
git checkout <commit>
# build and test
git checkout <previous-branch>
git stash pop
# or git stash apply
But I recommend git worktree. Suppose the version is abc123:
git worktree add /path/to/foo abc123
cd /path/to/foo
# build and test
The folders and files of abc123 are checked out into /path/to/foo. It does not affect the current main working tree. When the job is done in /path/to/foo, you can just remove the extra working tree by:
git worktree remove /path/to/foo
# or
rm -rf /path/to/foo
git worktree prune

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.

Why can't I see any android source files in working Directory?

I'm downloading Android source code using the following command.
repo init -u https://android.googlesource.com/platform/manifest -b Android-4.1.2_r1
repo sync
I've almost downloaded about 1.4 GB of files, but there is no source code in working directory. Working Directory has only one folder ".repo" (Which is about 1.4 GB and does not seem to include source code).
Is this correct way to download android source code? If not, where am I going wrong?
Finally Got answer.This is working as it should!
First it fills up .repo folder, which can be huge(10 GB). Only after that repo script downloads android source code.
References:
1. After Repo sync, there are no files in the directory
2. What are the purpose of the bare git repositories in .repo/projects/ created by the Android repo script?
If you want to work with android you will want to install the Android SDK. This page explains how:
http://developer.android.com/sdk/installing/index.html
From the SDK Manager, found in the tools directory, you can download any version of Androids source code you would like.
The Android source code actually has an empty master branch.
Unless you specify a particular branch to repo, it will always pull the master branch.
The reason that Android has an empty master branch for many of its repositories is because, the user is expected to use a particular version of the Android source rather than the latest.
(The latest is also typically a branch..but not master)
try something like this
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
You should see files other than just the .repo folder

How do I create a branch using git and repo tools while working with android code

I downloaded the android code from source.android.com. Then I created a new branch from this code:
repo start mybranch platform/external/webkit
Then I tried to switch to the new branch using :
git checkout mybranch
which failed with this error message:
fatal: Not a git repository (or any parent up to mount parent /media)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not
set).
I tried the steps mentioned in the android link.
One more problem: when I use the command
repo branch
it shows only the branch which I created eailer. How can I switch between the code I have downloaded and the code I have made changes to?
The android source consists of several hundred git repositories. The repo tool helps maintain all these repositories.
Therefore when you are directly in the root of your android clone, you are not actually in a git repository. You have to enter a sub-directory containing a git repository before you can start using git commands.
For example the build/ directory is a git repository itself, you can try:
$ cd build/
$ git checkout mybranch
Which sub-directory you need to enter of cause depends on where you want to modify the android source. :)

What happens behind the scenes when I do a repo sync?

What happens behind the scenes when I do a repo sync in my Android repository?
Is it equivalent to repo forall -c "git pull" or maybe git fetch? Or does it do something more complex?
Thanks
There's a description on this page of what repo sync does. In the usual case it will be more like git pull --rebase than git pull. To quote what that page says:
How Repo synchronization works
When you run repo sync, this is what happens:
If the project has never been synchronized, then repo sync is equivalent to git clone. All branches in the remote repository are copied to the local project directory.
If the project has already been synchronized once, then repo sync is equivalent to:
git remote update
git rebase origin/branch
where branch is the currently checked-out branch in the local project directory. If the local branch is not tracking a branch in the remote repository, then no synchronization will occur for the project.
If the git rebase operation results in merge conflicts, you will need to use the normal Git commands (for example, git rebase --continue) to resolve the conflicts.
The repo sync command also updates the private repositories in the .repo/ directory.
Essentially the git remote update makes sure that your remote-tracking branches (including origin/branch) are up-to-date by running git fetch origin. (In fact, the behaviour of git remote update is more complex than that, and depends on your git config, but in a typical setup it'll run git fetch [remotename] for each of your remotes.) Then the git rebase origin/branch rewrites your branch by replaying all your commits that aren't present upstream onto origin/branch.

Categories

Resources