I posted this question at Android Enthusiasts but figured it was the wrong place to ask, so I deleted it from there and asking it "again" here.
This is such a noob question, and pardon me if it is, but I just want to understand the underlying concepts clearly. Reading repo help and Google's repo command reference page doesn't really enlighten much. I understood some bits from Google's reference page, but I still need some more clarifications.
Following the instructions on how to download android source, I executed these two commands on an Ubuntu shell: (I've taken cared of all the prerequisites for the environment.)
~/android4.2.2$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.2.2_r1.2
~/android4.2.2$ repo sync -j4
After waiting half a day for repo to finish downloading, I ended up with 19G of downloaded material in android4.2.2 directory. So what exactly just happened, and why did it reach 19G when Google said I should only be expecting around 8G of source files?
repo is a python wrapper script for git, its Google Source page defines it as
repo - The Multiple Git Repository Tool
repo init command initializes repo in the current directory. That's, it downloads the latest repo source and a manifest.xml file that describes the directory structure of the git repositories, and store all of these in .repo sub-directory in the current directory. In your case, you have used an optional -b argument which is used to select the branch to checkout. By default (i.e., when -b argument is not used), master branch is used.
repo sync updates working tree to the latest revision. That's, it synchronizes local project directories with the remote repositories specified in the manifest file. If a local
project does not yet exist, it will clone a new local directory from the remote repository and set up tracking branches as specified in the manifest. If the local project already exists, it will update the remote branches and rebase any new local changes on top of the new remote changes. -j argument is used to set number of parallel jobs to execute. The default value can be defined in the manifest, and also can be overridden in command line as in your case.
why did it reach 19G when Google said I should only be expecting around 8G of source files?
That should be because besides the source files, you will get all the history of Android since the beginning of the time :)
Hope this helps.
Related
To cut the story short, to run a convolutional neural network model, I need an special version of nolearn, which has a url of the form https://github.com/dnouri/nolearn/tree/1659e4811e498dc1f442d8e6486d0831f85255b4/nolearn . However, there are no Download as Zip buttons at the page, nor I can download it with
git clone https://github.com/dnouri/nolearn -branch 1659e4811e498dc1f442d8e6486d0831f85255b4/nolearn
Simply,
git clone https://github.com/dnouri/nolearn/tree/1659e4811e498dc1f442d8e6486d0831f85255b4/nolearn
does not work, too.
Even, I have no idea what should I search for in Google!
Note: This is the last version which provided support for the class Objective, i.e. the command from lasagne.objectives import Objective is no more supported!
This can help you:
How to clone a single branch in git?
Where specifies:
git clone <url> --branch <branch> --single-branch [<folder>]
Docu :
Git Clone
--[no-]single-branch
Clone only the history leading to the tip of a single branch, either specified by the --branch option or the primary
branch remote’s HEAD points at. When creating a shallow clone with the
--depth option, this is the default, unless --no-single-branch is given to fetch the histories near the tips of all branches. Further
fetches into the resulting repository will only update the
remote-tracking branch for the branch this option was used for the
initial cloning. If the HEAD at the remote did not point at any branch
when --single-branch clone was made, no remote-tracking branch is
created.
Other than in Subversion (SVN), git has separate namespaces for directories (file system folders), branches and tags. Thus https://github.com/dnouri/nolearn/tree/1659e4811e498dc1f442d8e6486d0831f85255b4/nolearn is not, per se, a branch. 1659e4811e498dc1f442d8e6486d0831f85255b4 is a commit ID, used here to refer to the revision created by the commit. dnouri/nolearn is the repository name on GitHub (repository nolearn on account dnouri) and the final nolearn in the URL is a directory within the content of revision 1659e4811e498dc1f442d8e6486d0831f85255b4.
The 'normal' way to get this code with git would be:
replicate the repository to your local machine
git clone https://github.com/dnouri/nolearn.git
(You can find this URL on the repository's page https://github.com/dnouri/nolearn, in the 'clone URL' field.)
enter the local repository
cd nolearn
check out the wanted revision
git checkout 1659e4811e498dc1f442d8e6486d0831f85255b4
change into the respective directory inside the repository
cd nolearn
This is the link to the .zip : https://github.com/dnouri/nolearn/archive/1659e4811e498dc1f442d8e6486d0831f85255b4.zip
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
A few days ago I create a repository with an android project that I have been working on. Since then I have deleted a number of files and have added a number of others. Now I want to push my new changes to github. How do I do that? What are the commands to issue? I know I have o commit and then push to master. But how do I tell git that I have added and deleted a number of files? Normally I just do git add . since normally I am adding stuff. But this time I have x new files and y deleted files.
You can use git add --all . to record all changes, including deletions. From the man page:
-A
--all
Like -u, but match against files in the working tree in addition to the index. That means that it will find new files as well as staging modified content and removing files that are no longer in the working tree.
If you want more granular control, use git rm <filespec> to remove files from the index.
After that, commit and push as usual.
To push my changes I do:
1. git add .
2. git commit -m "write my comments for change"
3. git push origin<< provide my credentials
I am trying to build android from source since I need to customize something at a lower level. I download the entire source code to build from scratch using the command:
repo init -u https://android.googlesource.com/platform/manifest -b android-4.4_r1
repo sync
The size is about 26gb. Only then did I realize that there was a simpler way to do this since a lot of modification were required and that was already done. What i had to do was :
repo init -u git://github.com/jamesonwilliams/platform_manifest.git -b android-4.4_r1.1
repo sync
Is there anyway I can use what I downloaded already . I tried issuing the above command in the same directory where I downloaded the original code form but it looks like it is starting from scratch.Any ideas?
Do repo init in a new folder for android-4.4_r1.1
Copy .repo/projects folder from previous repo (android-4.4_r1) in to new repo's .repo/
Now run repo sync and it will be faster, it should only fetch delta
I need to download src code of different android tags. Each time it takes half an hour and GIGS of space. Instead I'd prefer to switch to different tag. How can I do so?
cd android-4.0.4_r1.1
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.4_r1.1
repo sync
cd ../android-4.2.2_r1
repo init -u https://android.googlesource.com/platform/manifest -b android-4.2.2_r1
repo sync
What's the proper way to switch/update from android-4.0.4_r1.1 to android-4.2.2_r1?
As mentioned in the comments of the accepted answer, you can change the default revision in manifest.xml. There's a snippet about it in repo help init:
Switching Manifest Branches
To switch to another manifest branch, repo init -b otherbranch may be
used in an existing client. However, as this only updates the manifest,
a subsequent repo sync (or repo sync -d) is necessary to update the
working directory files.
This won't download everything fresh, but will perform the necessary git operations to checkout the correct branch/tag across projects. Actually, if you run it with --trace, you'll see it does a good bit more than just git checkout.
NOTE: If you use this method you must make sure you supply the exact same parameters to repo init as you had for your previous invocation. Specifically, if you supplied -g options, supply them again or repo sync will remove directories now unnecessary in the new set of groups.
You can fetch tags with :
git fetch
git fetch --tags
And do checkout by :
git checkout tag_name
Also if it is taking more time to sync than usual run below command in that repo :
git gc