I'm trying to do some contributing to Cyanogenmod. As per the directions at https://github.com/CyanogenMod/android_vendor_cm, I do the following:
repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0
repo sync
And, as expected, after a few hours I have the CM source! However, the documentation at http://source.android.com/source/developing.html is a little confusing.
Basic Workflow
The basic pattern of interacting with the repositories is as follows:
Use repo start to start a new topic branch.
Edit the files.
Use git add to stage changes.
Use git commit to commit changes.
Use repo upload to upload changes to the review server.
Since the documentation states "Repo is a repository management tool that we built on top of Git." I assumed that once I initialized an android repo (and the fact that the URL ended in .git) the repo automatically would contain such an environment that I could use git. When I tried to follow the Basic Workflow instructions, however, git complained that it didn't find a git repository. This makes sense because I only saw a .repo directory, and no .git directory, like git expects.
So, then, do I need to initialize my own git repository? The instructions aren't very clear on that.
Thanks!
In order to gain git functionality you must initialize it as a git repository.
Try moving to the directory you cloned and type git init.
Related
Here's my situation....
I have created a repository on GitHub of a project. I worked on the project on a different computer then that which I have created the repository on. I now need to update the GitHub with the changes. I'm working from Android Studio. It seems the only option I have is to either create a new repository. I want to know how to update my old one without having to clone it and modify it then upload changes.
When you worked on the separate computer did you clone the repo? If so you can just push your changes. If not, you'll need to setup a remote
first init a git repo if your work is not in a git repo
git init
then add a remote
git remote add origin https://github.com/user/repo.git
use git remote -v to verify
set upstream
git remote add upstream
then pull, commit, push your changes now that your remote is setup
https://help.github.com/articles/adding-a-remote/
make a new git repo on your new PC using git init, this will add your project to a new repo on your machine.
add all your source to this new repo using a
git commit -am "whatever description of changes made"
Now checkout a new branch, call it what you like, but something like
`git checkout -b new_work`
should do the trick.
Now switch back to your master branch using git checkout master and connect your repo to your remote git repository on github
git remote add origin https://github.com/user/repo.git
You can set the upstream then using
`git remote add upstream`
Next you pull the remote code into your master branch using
git pull https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git BRANCH_NAME
Now you can merge all your new changes back into the master branch as you would in your normal workflow using
`git merge new_work`
or whatever you called your new branch.
Then push the master back to github using
`git push`
This approach has the advantage of being able to track all your changes properly and reverse them if needs be or amend update as needed whilst keeping the original code in tact and is the normal workflow for git.
Of course in the future you would pull the repo from git before making any changes and you wouldn't have this problem.
Hope that helps
I'm working on a project where we have reached a milestone. My git repository is up to date and everything is working correctly. Our client has now updated their api's and we're unsure how it will affect our code.
What I want to do is create a branch (already done) and upload the full repository to the branch. So I will have the project duplicated, one in the master and one in the new branch. I will then work and commit to the new branch leaving the master untouched. So going forward then for each release I can do the same, so we can fall back to the previous branch if there's any problem.
Can someone tell me how to do this please. I'm using Git and I'm working through a mac terminal.
I've gone through relevant questions on SO but I don't see the info I require, or perhaps I've missed it.
You don't upload a repository to a branch.
You have your code in a repository, and the repository has branches. No duplication, but you can get (checkout) master or the branch to set your working files to the version you want: master for untouched changes, branch for your recent changes.
Always good to do when you have reached a milestone is to tag the commit:
$ git tag v1.0
Then from there you can start a branch to work on integrating the new API
$ git checkout -b client_api_update
Work and commit in your branch. It does not affect the content in master, which you can checkout when you want to get your working files as they were in your milestone version (or checkout the tag).
When the integration of the new API is done, it's time to merge your branch to master in order to release support of the new API:
$ git checkout master
$ git merge client_api_update --no-ff
--no-ff is optional, but I think it makes for a more elegant history.
You are at a new milestone, so tag:
$ git tag v1.1
Here is how your history would look like:
/- v1.0 /- v1.1
A---B------------------G - master
\---C---D---E---F-/ - client_api_update
Let's say the branch you created in the main repo is <main_repo_new_branch>. Then the steps would be:
cd <local_repo_dir>
git remote add mainrepo <main_repo_dir>
git push mainrepo <local_repo_branch>:<main_repo_new_branch>
cd <main_repo_dir>
git checkout <main_repo_new_branch>
I have a whole android project code,it is very different from google's,because a team have developed on it for one year.Now I decide to use git instead of svn.And I want to use repo script to maintain the project.How to transfer?I've try to mirror a git server from Google via
repo init -u https://android.googlesource.com/mirror/manifest --mirror
then build my branch,but when I merge my project code to it,it is too difficult.
Is there a easy way?Thanks!
I am working on this same issue, the most progress I have made is due to this google group discussion.
From what I can tell you are going to have to maintain projects individually using git (I think you can do a repo start instead of git branch to setup your branches, then when you are ready to push changes you can use git push to the mirror. The thing you can gain from the repo script is the ability to use repo sync to sync all of the projects, and repo start to make new branches.
Could you be more specific about the problem you ran into with the merge? I may be able to help more on that front.
all
I have downloaded source code from google android website following google's guide. My purpose is to create a local branch to track remote branch
take framework/media for example, you can see .git under this directory, but when you run
git branch
the output is
*no branch
I crate my local branch using
git checkout -b local
then I have the problem, how can I switch back to track remote branch, I cannot pull updated source code from google for this .git again. There is only one local branch.
I also tried
git remote
and get
aosp https://android.googlesource.com/platform/frameworks/base (fetch)
aosp https://android.googlesource.com/platform/frameworks/base (push)
git branch --track local aosp
but I get the error
fatal: Not a valid object name: aosp
Anybody can give me some advice and guide? thanks very much.
You can use...
git branch --track local aosp/master
(The reason you're getting an error is because aosp is a remote, not a specific thing on that remote. aosp/master refers to the master branch on that remote, and thus can be tracked.)
As mentioned in "How do you make an existing git branch track a remote branch?"
As of Git 1.7.0:
git branch --set-upstream local aosp/local
will work too.
Note that for git 1.8+, discussions are in progress in order to make aosp/local an argument of --set-upstream (instead of a separate parameter).
In order to make its usage unambiguous, and to allow it to be used w/o specifying the current branch, require it to take an argument like so:
(master)$ git branch --set-upstream=origin/master
When I wanted to get Android source code, I knew that I have to use "repo". So what is repo? Why do they use repo and not just use GIT?, and is there a GUI for repo that enables me to pause/resume syncing, because every time I get disconnected occasionally it seems that repo starts syncing from the beginning!
As is mentioned in the android webpage, repo does not replace git. It is just a tool over git and helps you to manage multiple git repositories.
For example, suppose I have a big project which has a lot of features and I have several teams working on each feature and I created one repository for each feature. For example suppose my repositories are wifi, telephony, power management, etc. This action has sense when your features have different life cycles. For example if I won't touch the wifi feature in my next release and but I will modify all the rest. So under this scenario, my project or product is distributed in several different git repositories.
So, to get a centralized photo of my project (one specific moment of my project, for example a milestone), I need to get the revision (git hash or tag) of each repository. Remember that we have one repository for each feature. Manually I could do it but could be very painful. So, with repo you can have one MANIFEST which links to all the revisions of each git repo (one for each feature) and have an specific picture of my whole project.
Simply, I could say that is a way to manage centralized multiple git repositories which are decentralized.
With repo you have more features, not only to checkout at a specific point. For more info go to http://source.android.com/source/using-repo.html.
Repo and git - what they are, what they are for - is explained on source.android.com
To work with the Android code, you
will need to use both Git and Repo.
Git is an open-source version-control system designed to
handle very large projects that are
distributed over multiple
repositories. In the context of
Android, we use Git for local
operations such as local branching,
commits, diffs, and edits.
Repo is a tool that we built on top of Git. Repo helps us manage the
many Git repositories, does the
uploads to our revision control
system, and automates parts of the
Android development workflow. Repo is
not meant to replace Git, only to make
it easier to work with Git in the
context of Android. The repo command
is an executable Python script that
you can put anywhere in your path.
There's no GUI for Repo, as far as I can tell, but there's quite a bit of guidance on the site above for controlling what Repo is doing from the command line.
Concerning the pause and restart point, whilst in a terminal window doing a repo sync you can hit, "ctrl + z" to pause the repo sync. To restart simply type "fg" into the same window.
Go to:
http://source.android.com/source/git-repo.html
and you can download the repo script. It is a Python script that uses the git command to do distributed source code revision.
After you have executed repo sync, do a ps -auwf to see the processes:
For mine I saw:
\_ python -E /sde3/root/download/android/android/.repo/repo/main.py --rep
\_ git fetch korg
\_ git fetch korg
\_ git index-pack --stdin -v --fix-thin --keep=fetch-pack 5227 on
Yes, repo sync breaks often. But it is robust, just restart the command and it will resuming syncing again - those that have been updated will not be re-applied, so it will skip over them and continue with the rest.
repo sync has various useful options:
-f recovers from disconnects
-c just uploads the branch you asked for
-j <#CPUS> speeds up the sync by increasing the number of cpus used by the command