Skip to content

Commit 3894439

Browse files
dschogitster
authored andcommitted
Teach "git remote" a mirror mode
When using the "--mirror" option to "git remote add", the refs will not be stored in the refs/remotes/ namespace, but in the same location as on the remote side. This option probably only makes sense in a bare repository. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1e61b76 commit 3894439

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Documentation/git-remote.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ SYNOPSIS
1010
--------
1111
[verse]
1212
'git-remote'
13-
'git-remote' add [-t <branch>] [-m <branch>] [-f] <name> <url>
13+
'git-remote' add [-t <branch>] [-m <branch>] [-f] [--mirror] <name> <url>
1414
'git-remote' show <name>
1515
'git-remote' prune <name>
1616
'git-remote' update [group]
@@ -45,6 +45,10 @@ multiple branches without grabbing all branches.
4545
With `-m <master>` option, `$GIT_DIR/remotes/<name>/HEAD` is set
4646
up to point at remote's `<master>` branch instead of whatever
4747
branch the `HEAD` at the remote repository actually points at.
48+
+
49+
In mirror mode, enabled with `--mirror`, the refs will not be stored
50+
in the 'refs/remotes/' namespace, but in 'refs/heads/'. This option
51+
only makes sense in bare repositories.
4852

4953
'show'::
5054

git-remote.perl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,9 @@ sub add_remote {
278278

279279
for (@$track) {
280280
$git->command('config', '--add', "remote.$name.fetch",
281-
"+refs/heads/$_:refs/remotes/$name/$_");
281+
$opts->{'mirror'} ?
282+
"+refs/$_:refs/$_" :
283+
"+refs/heads/$_:refs/remotes/$name/$_");
282284
}
283285
if ($opts->{'fetch'}) {
284286
$git->command('fetch', $name);
@@ -409,6 +411,10 @@ sub add_usage {
409411
shift @ARGV;
410412
next;
411413
}
414+
if ($opt eq '--mirror') {
415+
$opts{'mirror'} = 1;
416+
next;
417+
}
412418
add_usage();
413419
}
414420
if (@ARGV != 3) {

0 commit comments

Comments
 (0)