Using repo to work with multiple GIT repositories

926 views
Skip to first unread message

kanagesh radhakrishnan

unread,
Dec 6, 2008, 2:54:19 AM12/6/08
to repo-d...@googlegroups.com
Hello All,

My work currently resides in four different source trees, namely:

* bootloaders (git://192.168.10.1/bootloaders)
* kernel (git://192.168.10.1/kernel)
* applications (git://192.168.10.1/apps)
* build (git://192.168.10.1/build)

I maintain them as four different git repositories. They are hosted
on a local server enabling any other developer to be able to clone
from one of the trees, make changes, commit locally and then push to
the git server.

I was browsing through the Android source code and found that they
have a similar situation where code is maintained in a large number of
independent GIT repositories. The tool 'repo' is being used to
initialize and sync each tree.

I have been trying to bring in this approach to maintain my work too.
I have had success to some extent :-) I have created a manifest.git
and repo.git in my local server. The default.xml file being
maintained in manifest.git has a list of the GIT repositories being
hosted by my local GIT server.

In order to clone the four GIT trees from the server, I do the following:

$ repo init -u git://192.168.10.1/manifest.git
$ repo sync

This clones from the four source trees maintained in the GIT server.

I am able to make changes locally in each tree and commit them.
However, when I attempt to push the commits to the main repository on
the GIT server, it always says that 'everything is up to date'

$ git push us...@192.168.10.1:/home/git/applications
us...@192.168.10.1's password:
Everything up-to-date

Further, when I try to pull in any recent updates with the git-pull
command, I get the following error:

$ git-pull
fatal: 'origin': unable to chdir or not a git archive
fatal: The remote end hung up unexpectedly

I know pushing to the repository on the GIT server works since I am
able to push local commits when I have cloned the working copy
manually (instead of using repo init and repo sync).
-----------------------------------------------------------------
$ git-clone git://192.168.10.1/applications
Initialized empty Git repository in /home/user/work/applications/.git/
remote: Counting objects: 6857, done.
remote: Compressing objects: 100% (3805/3805), done.
remote: Total 6857 (delta 2943), reused 6853 (delta 2941)
Receiving objects: 100% (6857/6857), 9.51 MiB | 10547 KiB/s, done.
Resolving deltas: 100% (2943/2943), done.
$

<edit, make changes, save, commit changes locally>

$ git-commit -a -m "Changed rule to build with custom tools"
Created commit bd55a06: Changed rule to build with custom tools
1 files changed, 1 insertions(+), 1 deletions(-)
$

<push changes to repository on GIT server>
$ git-push us...@192.168.10.1:/home/git/applications
us...@192.168.10.1's password:
Counting objects: 8, done.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 611 bytes, done.
Total 6 (delta 4), reused 0 (delta 0)
To us...@192.168.10.1:/home/git/applications
dce4bea..bd55a06 master -> master
$
-----------------------------------------------------------------

May I know what I have to look at to solve this problem? Has anyone
faced a similar problem? Any pointers would be of help.

Thanks in advance.

Regards,
Kanagesh

Shawn Pearce

unread,
Dec 8, 2008, 10:42:06 AM12/8/08
to repo-d...@googlegroups.com
On Fri, Dec 5, 2008 at 23:54, kanagesh radhakrishnan <rkan...@gmail.com> wrote:

In order to clone the four GIT trees from the server, I do the following:

 $ repo init -u git://192.168.10.1/manifest.git
 $ repo sync

This clones from the four source trees maintained in the GIT server.

I am able to make changes locally in each tree and commit them.
However, when I attempt to push the commits to the main repository on
the GIT server, it always says that 'everything is up to date'

 $ git push us...@192.168.10.1:/home/git/applications
 us...@192.168.10.1's password:
 Everything up-to-date

The problem here is you are using the "matching refs" push syntax.  Under this format of the command "git push" is looking at branches you have locally (what "git branch" outputs) and pushing only those which you have and which the remote has (what "git ls-remote --heads us...@192.168.10.1:/home/git/applications | sed s,.*refs/heads/,," outputs).

You should really get into the habit of specifying specific branches to push, e.g.:

  $ git push us...@192.168.10.1:/home/git/applications master

Please see the git push man page for more details, and/or the git mailing list.

Further, when I try to pull in any recent updates with the git-pull
command, I get the following error:

 $ git-pull
 fatal: 'origin': unable to chdir or not a git archive
 fatal: The remote end hung up unexpectedly

That's happening because "git pull" by default is executing "git pull origin", and the remote "origin" is not defined by default by repo.  Instead repo uses the remote name you set in your default.xml.  I can't say what name you have chosen, but Android uses "korg" for the remote repositories at android.git.kernel.org.  Thus with Android this needs to be "git pull korg".

The preferred approach though with repo is to use "repo sync" instead of "git pull".  You can limit it to just the current repository with "repo sync .".

The reason why repo sync is preferred over git pull is repo sync understands how the manifest works and is able to make sure it is fetching the proper branch from the remote repository.  In some configurations the manifest may be pointing repository A to use branch "master" while repository B uses "experimental".  Knowing which branch to pull requires looking at the manifest.  Git doesn't know the repo manifest, but repo does.
 
May I know what I have to look at to solve this problem?  Has anyone
faced a similar problem?  Any pointers would be of help.

So really you are just running into the differences between repo and git.  repo has made some design decisions and tradeoffs where it differs from traditional git behavior.

kanagesh radhakrishnan

unread,
Dec 8, 2008, 10:42:26 PM12/8/08
to repo-d...@googlegroups.com

Hello Shawn,

Thank you very much for the clear explanation.

Regards,
Kanagesh.

Reply all
Reply to author
Forward
0 new messages