I have used this command to archive a git source code:
git archive --format=tgz -o ~/myproj-20180402.tgz --prefix=myproj/ master
Are there same/similar way to archive a AOSP repo branch or tag. How to do ? Any help would be greatly appreciated.
AOSP code is not a single git project, it's actually many more (hundreds). So there is not a git command per-se.
What you could do is use repo this way:
repo forall -j16 "<your-git-command-1; your-git-command-2>"
So for the exact git command you proposed it would be:
repo forall -j16 "git archive --format=tgz -o ~/myproj-20180402.tgz --prefix=myproj/ master"
But keep in mind there is not a single git project, so you will end up with hundreds of archives, each inside it's root dir. Check the manifest you sync for a full list of projects and it's location locally.
Related
From the title of my question you can see what my problem is. I have an app on GitHub but I don't have .gitnore file. Now I want to make that file. I read somewhere that I must delete some files with terminal(Ubuntu) and then to make new .gitnore file.
Could someone tell me how to do all that stuff?
EDIT: I followed a solution from another question but when I write it into the terminal I received this:
dev3#dev3-All-Series:~$ git rm --cached
fatal: Not a git repository (or any of the parent directories): .git
dev3#dev3-All-Series:~$
You can remove the files on your local machine, and push to the repository. If the files are removed there, thén you can make the .gitnore file. That way, you don't end up with useless 'dead' folders or files on your repo. This way you don't need local access to the files, just your git client.
If you add the .gitnore first, you won't be able to delete the files because they will be ignored :).
If you already have a .gitnore file setup, you can do the following to remove files:
You can remove them from the repository manually:
git rm --cached file1 file2 dir/file3
Or, if you have a lot of files:
git rm --cached `git ls-files -i --exclude-from=.gitignore`
But this doesn't seem to work in Git Bash on Windows. It produces an error message. The following works better:
git ls-files -i --exclude-from=.gitignore | xargs git rm --cached
(found that solution here)
I executed these commands on intranet server (initialized empty Git repository in /home/git/project/):
mkdir project
cd project
git init --bare
Then I executed these commands on client:
git clone git#server:project
Then copied android source code (directory: alps/) to project
git status
git add .
git commit -m "xxx"
git push origin master
When this operation was done, I deleted the project and cloned it from server again. Some files were lost (e.g.:some .mk files in alps/external/chromium_org)
Why did it happen?
Most probably you've got the .mk extension in your .gitignore file. The file is in the project root directory. It may be hidden.
If you're sure that you want .mk files under source control, find a line with it in the .gitignore and delete that line.
Then:
git add .gitignore
git commit -m'removed .mk from .gitignore'
git add --all
git commit -m'tracked .mk files'
By the way, a good sample of .gitignore for Android can be found in GitHub default .gitignore files.
What is the use of the below two commands :
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
repo init -u https://android.googlesource.com/platform/manifest
I have already done this in the WORKING_DIRECTORY for one Download.Now I want to use the same repo and same manifest but in some other folder (out side WORKING_DIRECTORY).
Where can I see the Android Manifest file and what does it signifies ?
Is it mandatory to run the above two commands in the new directory , where my repo is already exported in the PATH.
thnx and Rgds,
Rp
repo is a tool to use multiple git repositories as one big meta repository.
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
Downloads (installs) the repo tool into your bin directory (used roughly like Program Files in Windows). That step is required only once. Afterwards you should be able to use repo from the command line in every directory.
$ repo init -u https://android.googlesource.com/platform/manifest
Initiates such a meta repository based on the manifest xml file (content of default.xml). That file contains a list of git repositories and paths for them. repo init does more or less git clone for each specified git.
$ repo sync
goes through all git repositories and downloads & updates their content in the directories that were created by the previous command. You could do git pull --rebase for each git yourself but that would take quite the time since Android consists of 40 or so git repositories.
The first command (curl), if performed without modification, needs only be run once on your system (unless the repo tool is updated, in which case you must run it again to get the latest). This is because its output, the repo command, is not in your current directory, it's relative to youor home directory instead.
The "repo" command must be run again when you wish to download the repo to a new working tree.
I've just cloned the Android kernel (via git clone) repository but for some reason, none of the source files are there. Instead there is just a massive .git folder, which I think has the kernel source code in it. How do I 'unpack' that git repository so I can get a workable source tree?
The exact command I've used was git clone git://android.git.kernel.org/kernel/common.git android-kernel.
git config core.bare returns false
git branch returns * master
git checkout master returns Already on 'master
The files seem to be there but they are packed. I really don't care about preserving integrity of the repository, I just want the source tree, without any of that stupid git crap.
In android they use their own tooling which uses git under the hood:
I am not sure how to get a kernel built working if you directly clone git repo, for their own tooling here are the docs:
http://source.android.com/source/downloading.html
Old question, but - The answer above is, indeed, incorrect. You have to cd to the directory you've cloned, then run git branch -a, and checkout the relevant one:
bash-3.2# git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/android-2.6.39
remotes/origin/android-3.0
remotes/origin/android-3.3
remotes/origin/android-3.4
remotes/origin/android-3.4-compat
remotes/origin/coupled-cpuidle
remotes/origin/experimental/android-3.8
remotes/origin/experimental/android-3.9-rc2
remotes/origin/linux-bcm43xx-2.6.39
remotes/origin/master
Then:
bash-3.2# git checkout android-3.4
Checking out files: 100% (38819/38819), done.
Branch android-3.4 set up to track remote branch android-3.4 from origin.
Switched to a new branch 'android-3.4'
Then, at last:
bash-3.2# ls
.git Documentation README drivers ipc samples usr
.gitignore Kbuild REPORTING-BUGS firmware kernel scripts virt
.mailmap Kconfig arch fs lib security
COPYING MAINTAINERS block include mm sound
CREDITS Makefile crypto init net tools
The Android source is a large hierarchy of git repositories. They are managed by a custom script called repo. Repo determines which git repositories to manage using a manifest.xml. The manifest.xml of Android is hosted in a git repository along with all the other git repositories.
How is this repository managed in Android? Specifically how are the different branches and the different files hosted in each branch organised?
First, repo init creates the .repo directory, clones the git repository https://android.googlesource.com/tools/repo to .repo/repo, and the git repository specified with the -u option to a bare repository at .repo/manifests.git. After that, it creates the .repo/manifests directory, converts it into a git repository through creating symbolic links from .repo/manifests/.git to .repo/manifests.git. It then checks out the branch specified in -b, and creates a symbolic link .repo/manifest.xml pointing to the specified file (-m option) in .repo/manifests, by default .repo/manifests/default.xml.
Roughly as follows:
repo init -u $URL -b $BRANCH -m $MANIFEST
--------------------
mkdir .repo; cd .repo
git clone https://android.googlesource.com/tools/repo
git clone --bare $URL manifests.git
mkdir -p manifests/.git; cd manifests/.git
for i in ../../manifests.git/*; do ln -s $ı .; done
cd ..
git checkout $BRANCH -- .
cd ..
ln -s manifests/$MANIFEST manifest.xml
You can trace what really happens with repo --trace init ...
Then, repo sync clones git repositories to .repo/projects for each project in manifest.xml and local_manifest.xml, creates working directories with .git having symlinks to the corresponding bare repository, checks out the branch specified in the manifest, and updates .repo/project.list. The case where the projects are already there is slightly different, essentially performing a git pull --rebase.
At the root of the repo is a hidden directory named ".repo". Inside you will find a git project named "manifests" which usually contains a file named "default.xml". This file contains information about all the projects and where their associated git repositories are located. This file is also versioned thus when you use the "repo init -b XYZ" command it will be reverted and you can back to older branches that may have added/removed git projects compared to the head.
Here is a link to the git repo document describing the manifest format:
https://gerrit.googlesource.com/git-repo/+/master/docs/manifest-format.md