How can I do sync from repo to GIT repository?

1,368 views
Skip to first unread message

lingy...@gmail.com

unread,
Dec 25, 2008, 2:06:05 AM12/25/08
to Repo and Gerrit Discussion
All,

Merry Christmas !

I have an android repo, and I created a git repository with submodules
from this repo.

since my android repo will always sync up from android.git.kernel.org,
my git repository needs to be updated from android repo accordingly.
Is there a tool I can use to sync up from repo to git repository ?

Thank you in advance !

Emily


Shawn Pearce

unread,
Dec 27, 2008, 12:15:23 PM12/27/08
to repo-d...@googlegroups.com
I think you'll just have to write a script that uses git fetch from each of your repo client projects into your git submodule projects, then updates the super git project with the latest commit.

Kenny Yu

unread,
Dec 27, 2008, 12:32:35 PM12/27/08
to Repo and Gerrit Discussion
If I understand the question, the issue is about the "git fetch" and
your working tree/index. "git fetch" will update your local repository
to align to remote "korg", while your local submobules and working
tree should be added to index always. Then it's upon you to merge the
remote HEAD to your submobules' MERGE_HEAD.

Is this answering you?

Kenny
On Dec 28, 1:15 am, Shawn Pearce <s...@google.com> wrote:
> I think you'll just have to write a script that uses git fetch from each of
> your repo client projects into your git submodule projects, then updates the
> super git project with the latest commit.
>
> On Wed, Dec 24, 2008 at 23:06, lingyan....@gmail.com
> <lingyan....@gmail.com>wrote:

lingy...@gmail.com

unread,
Dec 29, 2008, 1:15:23 AM12/29/08
to Repo and Gerrit Discussion
Shawn, Kenny,

I have one android repo named android_repo which is gotten from
android.git.kernel.org, and I created a git repository named
android_git with submodules
from android_repo.

My question is:

1. When I create a new repository android_A by cloning from
android_git, and run "git submodule init", I find that submodule
register URL is android_repo rather than android_git. Is it right?

For example,

$ git clone git://host.xz/android_git android_A
Initialized empty Git repository in /android_git/.git/
remote: Counting objects: 16, done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 16 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (16/16), 5.22 KiB, done.

$ cd android_A/
$ git submodule init
Submodule 'bionic' (git://host.xz/android_repo/bionic) registered for
path 'bionic'
Submodule 'bootloader/legacy' (git://host.xz/android_repo/bootloader/
legacy) registered for path 'bootloader/legacy'

2. In this case, if android_repo is updated by repo sync from
android.git.kernel.org, but android_git is not updated according, when
I run "git submodule update" in android_A, will android_A be updated
according to android_repo?

Thanks,
Emily
> > > Emily- Hide quoted text -
>
> - Show quoted text -

Shawn Pearce

unread,
Dec 29, 2008, 10:12:15 AM12/29/08
to repo-d...@googlegroups.com
On Sun, Dec 28, 2008 at 22:15, lingy...@gmail.com <lingy...@gmail.com> wrote:
1. When I create a new repository android_A by cloning from
android_git, and run "git submodule init", I find that submodule
register URL is android_repo rather than android_git. Is it right?

I think so, yes.  But I don't use git submodule so I'm not sure how its supposed to behave under any conditions.
 
2. In this case, if android_repo is updated by repo sync from
android.git.kernel.org, but android_git is not updated according, when
I run "git submodule update" in android_A, will android_A be updated
according to android_repo?

Only if the android_repo was created by "repo init --mirror".  If it was created without the --mirror flag then you need to make sure the working directory updated to the latest revision.  If you aren't making any changes in android_repo than that should always succeed during "repo sync".


Can I ask, why are you importing into git submodule?

lingy...@gmail.com

unread,
Dec 29, 2008, 9:03:55 PM12/29/08
to Repo and Gerrit Discussion
Shawn,

I want to do something like configuration management on source code. I
want to public my android repo to all development team. Developer can
clone it, and make changes in their local repo, then I can pull their
changes to my public repo. When build, test is OK, I'll make a tag.
At the same time, my android repo also needs to sync up with
android.git.kernel.org. Developer needs to do rebase, sync, and get
new source code to continue their work.
I was blocked on how developer get my repo, so I created a git
repository with submoudles from my repo. Then developer can use git
clone to get my repo's source code easily.
Do you have any suggestion ?

Thanks,
Emily

On Dec 29, 11:12 pm, Shawn Pearce <s...@google.com> wrote:
> On Sun, Dec 28, 2008 at 22:15, lingyan....@gmail.com
> <lingyan....@gmail.com>wrote:

Shawn Pearce

unread,
Dec 30, 2008, 10:26:16 AM12/30/08
to repo-d...@googlegroups.com
Use "repo init --mirror" to create a forest of bare Git repositories.  This is the group that you run "repo sync" in every so often in order to keep current with the rest of Android.

Make a temporary clone of platform/manifest.git using standard Git tools so you can edit the default.xml to change the URL for the projects to point to your server, rather than the public android.git.kernel.org.  Push that change into your own branch, e.g. "lingyan.ren-master" instead of just "master".

Ask users to init from your platform/manifest.git:

  repo init git://your.server/platform/manifest.git -b lingyan.ren-master

Because you edited the manifest they are looking at to use your own server, and not the public one, their repo client will look at your server.

To also make them use the tools/repo.git from your server you'll need to give them a modified copy of the "repo" script; just edit the top where REPO_URL is defined and have it point to your own repo.git.

This needs to be easier.  But I've been so bogged down in Gerrit 2 that I haven't been able to spend any time on repo.  And those who do need this to be easier on the list seem relatively content with this approach, or with adding a url.insteadOf entry to ~/.gitconfig.  Nobody has proposed any changes to improve it...

lingy...@gmail.com

unread,
Jan 6, 2009, 2:49:36 AM1/6/09
to Repo and Gerrit Discussion
Shawn,

Thank you for your guide !

I've setup a repo mirror successfully, People can repo init from my
platform/manifest.git.

Now I meet some new issues, could you please help me ?
1. The scene is that I have a repo mirror from android.git.kernel.org.
Some build engineers can init from my repo platform/manifest.git.
Now the issue is Developer need to init from build engineers's repo.
How to realize it?

As you know, the directory structure is different.
My repo mirror's diretory includes:
kernel platform repo.git

Build engineer's repo directory includes:
bionic build development frameworks kernel packages system
bootable dalvik external hardware Makefile

How can developers repo init from build engineer's repo? Need build
engineer create a repo mirror ? How ?

2. Can repo get code according to specified tag from other's repo?

3. As you know, there's no master branch in initial repo. If I created
a new branch, and did some work, then I want to remove this branch, it
always shows can't remove currently active branch. Do you know how to
remove it?

Thanks,
Emily

>
> repo init git://your.server/platform/manifest.git -b lingyan.ren-master

On Dec 30 2008, 11:26 pm, Shawn Pearce <s...@google.com> wrote:
> Use "repo init --mirror" to create a forest of bare Git repositories.  This
> is the group that you run "repo sync" in every so often in order to keep
> current with the rest of Android.
>
> Make a temporary clone of platform/manifest.git using standard Git tools so
> you can edit the default.xml to change the URL for the projects to point to
> your server, rather than the public android.git.kernel.org.  Push that
> change into your own branch, e.g. "lingyan.ren-master" instead of just
> "master".
>
> Ask users to init from your platform/manifest.git:
>
>   repo init git://your.server/platform/manifest.git -b lingyan.ren-master
>
> Because you edited the manifest they are looking at to use your own server,
> and not the public one, their repo client will look at your server.
>
> To also make them use the tools/repo.git from your server you'll need to
> give them a modified copy of the "repo" script; just edit the top where
> REPO_URL is defined and have it point to your own repo.git.
>
> This needs to be easier.  But I've been so bogged down in Gerrit 2 that I
> haven't been able to spend any time on repo.  And those who do need this to
> be easier on the list seem relatively content with this approach, or with
> adding a url.insteadOf entry to ~/.gitconfig.  Nobody has proposed any
> changes to improve it...
>
> On Mon, Dec 29, 2008 at 18:03, lingyan....@gmail.com
> <lingyan....@gmail.com>wrote:
> > > Can I ask, why are you importing into git submodule?- Hide quoted text -

Shawn Pearce

unread,
Jan 6, 2009, 1:52:17 PM1/6/09
to repo-d...@googlegroups.com
On Mon, Jan 5, 2009 at 23:49, lingy...@gmail.com <lingy...@gmail.com> wrote:

Now I meet some new issues, could you please help me ?
1. The scene is that I have a repo mirror from android.git.kernel.org.
Some build engineers can init from my repo platform/manifest.git.
Now the issue is Developer need to init from build engineers's repo.
How to realize it?

Its not supported.  The developer would need to create a mirror from your mirror, then create their repository from their mirror, and push back to the mirror so others can init from it.

You can obviously use standard Git to push to a mirror after it has been created, so a developer can still publish work in their current client by making a new mirror and then doing something like:

  repo forall -c 'git remote add me /path/to/me-mirror/$REPO_PROJECT.git"

Then they can push a branch with:

  git push me branchname

I want to change the layout of projects under $TOP/.repo/projects to match that of a mirror so that repo can init from an existing client by jumping into .repo/projects if it was pointed at a repo client.  I just haven't had the time to code this as I have been very focused on Gerrit2.  We really need to get that finished and switch the Android project over.

2. Can repo get code according to specified tag from other's repo?

Its ugly.  The easiest answer I have for you right now is to create a unique manifest file, set all of the revision fields as necessary, then put that file into a branch in the manifest project.  Branch/tag, same difference in Git really, though a tag can have an optional GnuPG signature attached to it.  If you really need that in the manifest project, create both a branch and a tag pointing to the same commit.  Then you can "repo init -b thebranch" and "git describe" will still generate exactly the tag name.

Yea, it should be easier.  But the basic theory of how platform tags will be created by the CTT about every ~6 months will be to build a new manifest, peg the revision numbers, and fork off a branch so bug fixes have a place to go.  So this is roughly in line with the theory of how Android will be maintained in the future.

3. As you know, there's no master branch in initial repo. If I created
a new branch, and did some work, then I want to remove this branch, it
always shows can't remove currently active branch. Do you know how to
remove it?

git checkout m/master

where the name after m/ is the branch name you used when you did "repo init -b $branch".  E.g. if it was "repo init -b cupcake" then "git checkout m/cupcake".

After you have detached your HEAD by this command you can now delete the branch with "git branch -d $name" or "git branch -D $name".

Robert K. Barrett

unread,
Jan 6, 2009, 2:04:27 PM1/6/09
to repo-d...@googlegroups.com
I am so lost man
2 Corinthians 13:14

The grace of the Lord Jesus Christ, and the love of God, and
the communion of the Holy Spirit be with you all. Amen.

Smile, someone loves you.

lingy...@gmail.com

unread,
Jan 8, 2009, 9:01:01 PM1/8/09
to Repo and Gerrit Discussion
Shawn,

Thank you ! I followed your guide, it works !

I have another question, how can I apply tag on all source code in
android repo rather than on specified branch ?

Thanks,
Emily

On Jan 7, 3:04 am, "Robert K. Barrett" <deaf...@tmail.com> wrote:
> I am so lost man
>
>
>
> On Tue, 6 Jan 2009 12:52 pm, Shawn Pearce wrote:
> Smile, someone loves you.- Hide quoted text -

Shawn Pearce

unread,
Jan 8, 2009, 9:07:47 PM1/8/09
to repo-d...@googlegroups.com
On Thu, Jan 8, 2009 at 18:01, lingy...@gmail.com <lingy...@gmail.com> wrote:

Thank you !  I followed your guide, it works !

I have another question, how can I apply tag on all source code in
android repo rather than on specified branch ?
 
repo forall -c git tag mytag

?

But you'll also want to edit your manifest, possibly creating a tag specific one, to make it easier for others to create a client from that same tag.

I'll admit, the tagging stuff is weak-to-non-existent in repo.  It hasn't been a problem for Android as an open source project yet, as there hasn't been a formal release from the open source repository.  Its still very much an active development project in its early stages.  So I've put off dealing with tags...

lingy...@gmail.com

unread,
Jan 12, 2009, 1:05:23 AM1/12/09
to Repo and Gerrit Discussion
Shawn,

I use the command "repo forall -c git tag mytag", it seems that all
projects dir is applied tag, while when I use gitk to check files,
files under projects are not tagged. Am I missed something?

/myandroid/packages/apps/Sync> git tag
AND_N_01.01.01I
android-1.0

Thanks,
Emily

On Jan 9, 10:07 am, Shawn Pearce <s...@google.com> wrote:
> On Thu, Jan 8, 2009 at 18:01, lingyan....@gmail.com
> <lingyan....@gmail.com>wrote:

Shawn Pearce

unread,
Jan 12, 2009, 10:51:19 AM1/12/09
to repo-d...@googlegroups.com
On Sun, Jan 11, 2009 at 22:05, lingy...@gmail.com <lingy...@gmail.com> wrote:

I use the command "repo forall -c git tag mytag", it seems that all
projects dir is applied tag, while when I use gitk to check files,
files under projects are not tagged. Am I missed something?

/myandroid/packages/apps/Sync> git tag
AND_N_01.01.01I
android-1.0

Uhh.  I'm not sure what you mean.  The command you list would apply a tag of the same name to all projects, tagging the currently checked out revision.  What do you mean "files under projects are not tagged"?  Git doesn't tag specific files, it tags snapshots.  Git is fundamentally a snapshot based system, not a file based system.

lingy...@gmail.com

unread,
Jan 12, 2009, 9:25:13 PM1/12/09
to Repo and Gerrit Discussion
Shawn,

Do you mean git tag is only applied on checkout revision ?

What I want to do likes this,
There are files A, B, C. I create a branch emily_test and modify file
C, then commit the change. I want to apply tag emily_tag on files A,B
and modified C. What should I do? If I use "git tag emily_tag", only
modified C is applied tag emily_tag.

Thanks,
Emily

On Jan 12, 11:51 pm, Shawn Pearce <s...@google.com> wrote:
> On Sun, Jan 11, 2009 at 22:05, lingyan....@gmail.com
> <lingyan....@gmail.com>wrote:

Shawn Pearce

unread,
Jan 12, 2009, 9:27:45 PM1/12/09
to repo-d...@googlegroups.com
You should go read about how Git implements tags.  It doesn't behave like other systems like ClearCase or CVS, where a tag is placed on a specific file.  It tags entire snapshots of a Git repository, which in Android amounts to an entire project (e.g. platform/dalvik).

lingy...@gmail.com

unread,
Jan 12, 2009, 9:39:12 PM1/12/09
to Repo and Gerrit Discussion
Shawn,

Thank you very much for your guide ! I'm looking at it now . :)

Emily

On Jan 13, 10:27 am, Shawn Pearce <s...@google.com> wrote:
> You should go read about how Git implements tags.  It doesn't behave like
> other systems like ClearCase or CVS, where a tag is placed on a specific
> file.  It tags entire snapshots of a Git repository, which in Android
> amounts to an entire project (e.g. platform/dalvik).
>
> On Mon, Jan 12, 2009 at 18:25, lingyan....@gmail.com
> <lingyan....@gmail.com>wrote:
>
>
>
>
>
> > Shawn,
>
> > Do you mean git tag is only applied on checkout revision ?
>
> > What I want to do likes this,
> > There are files A, B, C. I create a branch emily_test and modify file
> > C, then commit the change.  I want to apply tag emily_tag on files A,B
> > and modified C. What should I do? If I use "git tag emily_tag", only
> > modified C is applied tag emily_tag.
>
> > Thanks,
> > Emily
>
> > On Jan 12, 11:51 pm, Shawn Pearce <s...@google.com> wrote:
> > > On Sun, Jan 11, 2009 at 22:05, lingyan....@gmail.com
> > > <lingyan....@gmail.com>wrote:
>
> > > > I use the command "repo forall -c git tag mytag", it seems that all
> > > > projects dir is applied tag, while when I use gitk to check files,
> > > > files under projects are not tagged. Am I missed something?
>
> > > > /myandroid/packages/apps/Sync> git tag
> > > > AND_N_01.01.01I
> > > > android-1.0
>
> > > Uhh.  I'm not sure what you mean.  The command you list would apply a tag
> > of
> > > the same name to all projects, tagging the currently checked out
> > revision.
> > > What do you mean "files under projects are not tagged"?  Git doesn't tag
> > > specific files, it tags snapshots.  Git is fundamentally a snapshot based
> > > system, not a file based system.- Hide quoted text -
Reply all
Reply to author
Forward
0 new messages