From: "Magnus Bäck" <magnus.back@sonyericsson.com>
To: Ilya Basin <basinilya@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: merging bare repository
Date: Fri, 13 May 2011 15:53:48 +0200 [thread overview]
Message-ID: <20110513135348.GB10857@jpl.local> (raw)
In-Reply-To: <533718318.20110513145132@gmail.com>
On Friday, May 13, 2011 at 12:51 CEST,
Ilya Basin <basinilya@gmail.com> wrote:
> Hi list. Please suggest me a solution. There's a remote repository;
> we're not allowed to push to. We have several committers.
> So I want to create a local mirrror. We will push our changes to it.
> Once in a while I want to sync this repo with upstream.
Okay, so you're forking an upstream git and periodically merging from
it. Pretty standard behavior.
> Here's what I do:
>
> on server:
> [git@server]$ git clone --bare ssh://git@some.org/git/project.git /git/project.git
>
> on workstation:
> [me@client]$ git clone ssh://git@server/git/project.git
> [me@client]$ cd project
> [me@client]$ touch aaa
> [me@client]$ git add aaa
> [me@client]$ git commit aaa -m abracadabra
> [me@client]$ git push
>
> back on server:
> [git@server]$ git log
> commit e5c871122cadfa4ed4d2ab488852ecdb803b4bd8
> Author: Ilya Basin <>
> Date: Fri May 13 13:39:39 2011 +0400
>
> abracadabra
>
> I want to merge with upstream
> [git@server]$ git fetch
> [git@server]$ git merge origin
> fatal: This operation must be run in a work tree
Don't do the merge in the server-side bare git, do it somewhere you've
made a non-bare clone that has a worktree. A workstation would be the
best choice, but you could make such a clone on the server too (but I'd
avoid introducing a process in an organization that required people to
be able to logon to the Git server). Once you've actually done the merge
you can push the merge commit to the master branch of
ssh://git@server/git/project.git.
To deal with upstreams like this I recommend you place the upstream
branch(es) in a separate namespace prefixed by <upstreamname>/, e.g.
github/master if your upstream is the master branch from the official
Github repo of the project. Example:
git fetch ssh://git@some.org/git/project.git
git push ssh://git@server/git/project.git FETCH_HEAD:github/master
If you mirror the upstream branches like this on your server merges
from upstream becomes trivial[*],
git merge origin/github/master
git push ssh://git@server/git/project.git HEAD:master
and can be done on any workstation plus it's easy for your users to
e.g. see what they've been up to compared to the upstream:
git log origin/github/master..origin/master
You could update github/master as often as you wish, perhaps more often
than you do the actual merge to your own branch. That way your users can
easily keep track of what goodies await them in the next merge from
upstream.
[*] I'm being unnecessarily explicit in the push operation just to
show what's going on -- a plain "git push origin" will probably
do the same thing.
[...]
--
Magnus Bäck Opinions are my own and do not necessarily
SW Configuration Manager represent the ones of my employer, etc.
Sony Ericsson
next prev parent reply other threads:[~2011-05-13 14:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-13 10:51 merging bare repository Ilya Basin
2011-05-13 13:53 ` Magnus Bäck [this message]
2011-05-13 20:56 ` Enrico Weigelt
2011-05-31 2:01 ` garyc618
2011-06-06 21:54 ` Magnus Bäck
2011-05-13 13:54 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110513135348.GB10857@jpl.local \
--to=magnus.back@sonyericsson.com \
--cc=basinilya@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).