When initializing a non-bare repositories, you most likely want to avoid pushing into the current branch (because a push does not touch the working tree at all). Let's be nice to those users who have not read that part of the manual, and just outright refuse updating the current branch. To be nice to those users who wrote that part of the manual, let's do that in git-init, so that existing repositories are not affected. Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx> --- Documentation/git-init.txt | 4 ++++ builtin-init-db.c | 1 + 2 files changed, 5 insertions(+), 0 deletions(-) diff --git a/Documentation/git-init.txt b/Documentation/git-init.txt index 62914da..03a4f0e 100644 --- a/Documentation/git-init.txt +++ b/Documentation/git-init.txt @@ -56,6 +56,10 @@ By default, the configuration flag receive.denyNonFastForwards is enabled in shared repositories, so that you cannot force a non fast-forwarding push into it. +If you are initializing a non-bare repository, the config variable +`receive.guardCurrentBranch` is set to true. This avoids problems with +pushing into the current branch, which does not touch the working tree. + -- diff --git a/builtin-init-db.c b/builtin-init-db.c index 4f93d03..4542054 100644 --- a/builtin-init-db.c +++ b/builtin-init-db.c @@ -243,6 +243,7 @@ static int create_default_files(const char *template_path) else { const char *work_tree = get_git_work_tree(); git_config_set("core.bare", "false"); + git_config_set("receive.guardCurrentBranch", "true"); /* allow template config file to override the default */ if (log_all_ref_updates == -1) git_config_set("core.logallrefupdates", "true"); -- 1.5.5.rc1.174.g591a9 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html