I'm very new at GIT, apologize if this is a basic question however I couldn't seem to find a similar situation after searching google and stackoverflow. Here's my scenario:
I have a git folder with the latest commit version that I do NOT perform any commit (I won't do any changes in the code in my local directory). Other people performs the commit on their computer, I just need to get a specific commit version, copy it to a working directory and build code. I'm planning to make a program to automatically perform these steps in repeated cycle everyday. Steps summarized below:
Get the latest commit in repo_folder
Go back to old commit version
Copy to a work_folder
Then build code in work_folder
I'm not sure if these steps are the correct/best way to do it. Also, how can I perform #2 correctly and how to make sure my program have retrieved the correct commit version? Is #3 necessary? Or can I just build code directly in repo_folder (might modify some files after build), then afterwards perform git command to get the latest commit version again?
Here's my steps actual steps
1. Get the latest commit in repo_folder
repo init -u ssh://username#git.aaa.com:1234/manifest.git -b branch -m file.xml
repo sync
After getting to the latest repo, I search through the logs and perform git reset --hard
2. Go back to old commit version
cd .repo/manifests
COMMITHASH=git log --grep=$keyword | head -1 | cut -d' ' -f2
git reset --hard $COMMITHASH
cp file.xml new_file.xml
repo init -m new_file.xml
After this command, I'm not sure how to check if my current version is correct.
Steps 3 and 4 just simple copy and build commands not related to this question.
cp -r repo_folder/folder1 work_folder/folder1
cp -r repo_folder/folder2 work_folder/folder2
run build.bat
Just clone your local master to a new directory and then checkout to the version that you currently need in that one:
No copying, no mucking about.
git clone -l /path/to/master /path/to/working
cd /path/to/working
git checkout -f REV_OR_BRANCH_ID
If you have any generated files such as objects it is a good idea to clean them up - such as with make clean after a checkout.
from then on you can:
cd /path/to/working
git pull
git checkout -f REV_OR_BRANCH_ID
Related
I am looking to download a specific version of android source code - android-4.4.4_r2. I followed the instructions provided on the "Downloading the Source" page of android source and used repo init -u https://android.googlesource.com/platform/manifest -b android-4.4.4_r2. And when I execute repo sync, it looks like the entire tree is getting downloaded. The current directory size of the download is 54G and is continuing to grow.
I am trying to fulfill the system requirement, as per instructions on https://github.com/huz123/GemDroid_QEMU.
Is there a different to way to download just the android-4.4.4_r2?
Or is it supposed to download the entire tree the first time (>54G)?
Please help me with the situation. Thank you!
Yes! the official documentation of hardware requirements is:
At least 100GB of free disk space for a checkout, 150GB for a single build, and 200GB or more for multiple builds. If you employ ccache, you will need even more space.
When working on the full OS system you'll have to handle large amount of data - the repo sync command can take you more than 5 hours and it's normal.
The make command that builds and compiles your project can also take some several hours on first time.
Step to download android source code(AOSP) in Ubuntu
First create one folder like "aosp-m" to copy AOSP code in your machine.
Open terminal(Ctrl+Alt+T) and change your Dir to latest created Dir let say "aosp-m"
After that Run the following command in terminal :-
git clone git://gitz01/cm/download/android/manifest
Run Following command in terminal one by one
git config --global user.name "Your Name"
git config --global user.email "you#example.com"
then run following command for repo init
repo init -u git://gitz01/cm/download/android/manifest -b master -m identifiedmanifest.xml
here you can replace identifiedmanifest.xml to your desired AOSP source code , Let Say android-6.0.1_r10.xml marshmellow.
and in the last run repo sync command. This command start downloading your desired AOSP code in your machine. This opertation take more than 1 hours(depending on your internet connection speed) to download source code.
Thats it... Happy Coding.......
I am starting to work on Android source code in Ubuntu and even if I am expert in Android App development, this part of Android is quite new to me so apologize for any stupid questions.
I started by creating my master branch locally with the following commands:
$ mkdir master
$ cd master
$ wget http://git.[myandroidrom]/repo
$ chmod +x repo
All working as expected, I end up with a folder called master and a file called repo inside it.
Second step I started the synchronization of my source code:
$ ./repo init -u http://git.[myandroidrom]/manifest -b [my specific rom branch]
$ ./repo sync
It took a while (few hours) after I got the folder master populated with all the folders mentioned into the Android source code documentation but they are all .git folders. So quite useless because in order to compile Android I need the real source code which is somehow packed into those .git folders.
What should be the next step to extract the content of this repository?
So actually the command repo sync create a folder .repo which contains the .git structure of android. If in the repo init you don't specify with -b a branch it will download the master branch.
After that, in order to have the real code you need to git clone the folder.
Example, I run the following command:
$ repo sync build
where build is the name of my project folder and in the root working directory I have now the source code for the folder build.
More info can be found at this URL:
https://source.android.com/source/developing.html
Being fairly new to Linux and very new to Git, this is proving to be.. problematic.
Can someone please direct me to or tell me the steps required (Ideally step by step) to do this?
I have a directory with my project in it, I want to commit that to Git, I know there is a .gitignore which ignores certain files etc. and I have used GitHub on Windows mainly for local respository stuff which is again the primary purpose now.
Any help on this would be greatly appreciated cheers!
Welcome to git and linux. Here are a few links to get you started
https://help.github.com/articles/set-up-git
http://git-scm.com/book
http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository
http://zrusin.blogspot.com/2007/09/git-cheat-sheet.html
Git for beginners: The definitive practical guide
There are a couple of different ways to do this. The easiest in my opinion is the command line.
Open up a terminal, and cd to the directory that contains the android project.
cd /home/bob/foo
ls
Initialize the git repo, this will create a hidden .git file inside the folder
git init
ls -a
Create your first commit, by adding all files to the working tree
git add .
git commit -m "My First Commit"
You will now have a master branch, and 1 commit. You can veiw your commit with the following commands
git status
git log
If you aren't comfortable using the command line yet, you could alternatively accomplish all of this with a gui. Here are some programs for linux.
https://git.wiki.kernel.org/index.php/InterfacesFrontendsAndTools#Graphical_Interfaces
You can do a simple
git init
in the command line (in the correct directory) to initialize your local repository. Then you just have to add your files and commit them :
git add .
git commit -m "first commit"
I strongly recommand you the read of the first chapters (at least) of the Pro Git free book to help you understand the basics.
I have downloaded whole working tree with the following command:
repo init -u https://android.googlesource.com/platform/manifest
repo sync -j8
After syncing successfully, I want to switch working tree to android 2.3.7.
You see I didn't specify branch with "-b" parameter when "repo init".
So I guess all tag info should be downloaded and I can easily switch to android 2.3.7 with the following command:
repo forall -c git checkout android-2.3.7_r1
But it produces many errors like:
error: pathspec 'android-2.3.7_r1' did not match any file(s) known to git.
So how can I switch to android 2.3.7 without "repo init -b android-2.3.7_r1" and "repo sync" again?
You cannot solve this problem using repo forall.
Lets assume for certainty that your current Android tree is clean - no local changes or commits, i.e. repo status shows nothing.
To properly switch Android version, all you need to change is branch for your manifest repository. First determine the available branches with manifests for the different Android versions:
cd $ANDROID_ROOT
cd .repo/manifests
git branch -av # see all available branches on origin
Select a version and
cd $ANDROID_ROOT
repo init -b <my_selected_android_version>
Such selective repo init with -b (without -u) will only update manifest branch and will not otherwise touch your tree.
Now, simply sync it:
repo sync -j8
and some time later, your Android tree will switch to another version.
Speed of this operation is mostly determined by how much default.xml manifest file differs between old and new Android versions - because if some git repository was added in new manifest, it will spend time cloning it. And if some repository was removed, if will actually blow it away.
But, by and large, this method is still much faster than initializing brand new Android tree from scratch.
if the branch you are in and the branch you will switch to has the same manifest.xml file, then you can use the following commands to do that.
repo forall -c git fetch aosp --tags
repo forall -c git checkout -b john5.1.1_r14_api22 android-5.1.1_r14
also see details in
http://johnliao52.github.io/2016/03/27/git-repo-skills.html
I feel I have a pretty good understanding of git, but when it comes to the repo command, I get lost. I've read about the repo command, but I'm still not sure how it ties everything together.
My biggest question is can I change my current branches from gingerbread to ICS and possibly back?
I see the command:
repo init -u https://android.googlesource.com/platform/manifest
From my understanding, this will create a repo with the master branch. If I want to specify the branch, I can do:
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
The download is about 8GB, I believe, so I don't want to have to blow my repo away if they share code. is there a way to switch branches in repo?
If you run repo init a second time with a different branch, you can simply repo sync and it will not download the entire source code again.
The second time you run repo init, just run it as
repo init -b different_branch
You don't need to provide the -u parameter again.
The repo -b parameter specifies the branch of the .repo/manifests git repository that should be checked out. The default.xml file in this repository defines which branch each of the other git repositiories (projects) should be on.
It seems that repo is written in such a way that if you check out another manifest branch are repo sync again it will pull all the code again over the network.
You can run repo forall -c 'git checkout branch_name' which will checkout the specified branch for all projects that are declared in your current manifest but if there are projects added/removed between gingerbread and ics (which there are), then you won't get the code for these projects.
Running git checkout branchname in the .repo/manifests repository then running repo sync may enable you to save some network overhead.
Otherwise, due to the limitations of repo, the only real way to do it is to maintain two working copies of the aosp or be prepared to re-sync.