Skip to content

Commit 7182135

Browse files
Petr BaudisJunio C Hamano
authored andcommitted
Make git-clone --use-separate-remote the default
We've talked about this for quite some time on the list, and it is a sane thing to do for a repository with an associcated working tree. For somebody who wants to use the traditional layout, there is a backward compatibility option --use-immingled-remote, but it is expected to be removed before the next major release. Signed-off-by: Petr Baudis <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 29561ad commit 7182135

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

Documentation/git-clone.txt

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ SYNOPSIS
1111
[verse]
1212
'git-clone' [--template=<template_directory>] [-l [-s]] [-q] [-n] [--bare]
1313
[-o <name>] [-u <upload-pack>] [--reference <repository>]
14-
[--use-separate-remote] <repository> [<directory>]
14+
[--use-separate-remote | --use-immingled-remote] <repository>
15+
[<directory>]
1516

1617
DESCRIPTION
1718
-----------
@@ -71,9 +72,13 @@ OPTIONS
7172
Make a 'bare' GIT repository. That is, instead of
7273
creating `<directory>` and placing the administrative
7374
files in `<directory>/.git`, make the `<directory>`
74-
itself the `$GIT_DIR`. This implies `-n` option. When
75-
this option is used, neither the `origin` branch nor the
76-
default `remotes/origin` file is created.
75+
itself the `$GIT_DIR`. This obviously implies the `-n`
76+
because there is nowhere to check out the working tree.
77+
Also the branch heads at the remote are copied directly
78+
to corresponding local branch heads, without mapping
79+
them to `refs/remotes/origin/`. When this option is
80+
used, neither the `origin` branch nor the default
81+
`remotes/origin` file is created.
7782

7883
--origin <name>::
7984
-o <name>::
@@ -97,8 +102,15 @@ OPTIONS
97102

98103
--use-separate-remote::
99104
Save remotes heads under `$GIT_DIR/remotes/origin/` instead
100-
of `$GIT_DIR/refs/heads/`. Only the master branch is saved
101-
in the latter.
105+
of `$GIT_DIR/refs/heads/`. Only the local master branch is
106+
saved in the latter. This is the default.
107+
108+
--use-immingled-remote::
109+
Save remotes heads in the same namespace as the local
110+
heads, `$GIT_DIR/refs/heads/'. In regular repositories,
111+
this is a legacy setup git-clone created by default in
112+
older Git versions, and will be removed before the next
113+
major release.
102114

103115
<repository>::
104116
The (possibly remote) repository to clone from. It can

git-clone.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ die() {
1414
}
1515

1616
usage() {
17-
die "Usage: $0 [--template=<template_directory>] [--use-separate-remote] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [-n] <repo> [<dir>]"
17+
die "Usage: $0 [--template=<template_directory>] [--use-immingled-remote] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [-n] <repo> [<dir>]"
1818
}
1919

2020
get_repo_base() {
@@ -115,7 +115,7 @@ bare=
115115
reference=
116116
origin=
117117
origin_override=
118-
use_separate_remote=
118+
use_separate_remote=t
119119
while
120120
case "$#,$1" in
121121
0,*) break ;;
@@ -134,7 +134,10 @@ while
134134
template="$1" ;;
135135
*,-q|*,--quiet) quiet=-q ;;
136136
*,--use-separate-remote)
137+
# default
137138
use_separate_remote=t ;;
139+
*,--use-immingled-remote)
140+
use_separate_remote= ;;
138141
1,--reference) usage ;;
139142
*,--reference)
140143
shift; reference="$1" ;;
@@ -169,18 +172,15 @@ repo="$1"
169172
test -n "$repo" ||
170173
die 'you must specify a repository to clone.'
171174

172-
# --bare implies --no-checkout
175+
# --bare implies --no-checkout and --use-immingled-remote
173176
if test yes = "$bare"
174177
then
175178
if test yes = "$origin_override"
176179
then
177180
die '--bare and --origin $origin options are incompatible.'
178181
fi
179-
if test t = "$use_separate_remote"
180-
then
181-
die '--bare and --use-separate-remote options are incompatible.'
182-
fi
183182
no_checkout=yes
183+
use_separate_remote=
184184
fi
185185

186186
if test -z "$origin"

0 commit comments

Comments
 (0)