在Git中使用receive.denyCurrentBranch有什么后果? [英] What are the consequences of using receive.denyCurrentBranch in Git?

查看:1907
本文介绍了在Git中使用receive.denyCurrentBranch有什么后果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Git仓库。我克隆了存储库并可以提交我的本地更改。当我将更改推送到服务器时它就起作用了。

只要我创建了一个分支,我就签出分支,提交我的工作,然后签出master分支。然后,我将我的本地更改合并到主分支中。当我尝试推送到服务器时,出现以下异常:

 欢迎使用Git(版本1.7.11-preview20120620)

运行'git help git'显示帮助索引。
运行'git help<命令>'以显示特定命令的帮助。

$ git push origin master:master
计数对象:9,完成。
使用多达4个线程的增量压缩。
压缩对象:100%(7/7),完成。
写作对象:100%(8/8),13.68 KiB,完成。
合计8(增量2),重用1(增量0)
开箱对象:100%(8/8),完成。
remote:error:拒绝更新签出分支:refs / heads / master
remote:error:默认情况下,更新非裸仓库中的当前分支
remote:error:is被拒绝,因为它会使索引和工作树不一致
remote:错误:用你推送的内容,并且需要'git reset --hard'来匹配
remote:error:工作树到HEAD 。
remote:错误:
remote:错误:您可以将'receive.denyCurrentBranch'配置变量设置为

remote:error:'ignore'或'warn'in the remote repository允许推入

remote:error:当前分支;然而,除非您
remote:error:安排更新其工作树以匹配您在某些

remote:error:其他方式中推送的内容,否则不建议这样做。
remote:error:
remote:error:要压制此消息并保持默认行为,请设置

remote:error:'receive.denyCurrentBranch'配置变量为'拒绝。
到c:/ jGit
! [remote rejected] master - > master(分支目前被检出)
错误:未能将一些ref推送到'c:/ gitRepository'

一个解决方案是运行以​​下命令:

  git config receive.denyCurrentBranch忽略

code>

在此之后,它可以工作,但我想知道为什么我需要使用此选项。这是唯一的选择吗?这样做的后果是什么?



我真正想做的是创建分支,将它们合并到主分支中,然后将更改推送到服务器。

解决方案

您推送的服务器应使用裸存储库。



如何转换一个正常的Git仓库到一个裸露的?


I have a Git repository. I have cloned the repository and can commit my local changes. When I push my changes to the server it works.

As soon as I create a branch, I checkout the branch, commit my work and then checkout the master branch. I then merge my local changes into the master branch. When I try to push to the server I get the following exception:

Welcome to Git (version 1.7.11-preview20120620)

Run 'git help git' to display the help index.
Run 'git help <command>' to display help for specific commands.

$ git push origin master:master
 Counting objects: 9, done.
 Delta compression using up to 4 threads.
 Compressing objects: 100% (7/7), done.
 Writing objects: 100% (8/8), 13.68 KiB, done.
 Total 8 (delta 2), reused 1 (delta 0)
 Unpacking objects: 100% (8/8), done.
 remote: error: refusing to update checked out branch: refs/heads/master
 remote: error: By default, updating the current branch in a non-bare repository
 remote: error: is denied, because it will make the index and work tree inconsistent
 remote: error: with what you pushed, and will require 'git reset --hard' to match
 remote: error: the work tree to HEAD.
 remote: error:
 remote: error: You can set 'receive.denyCurrentBranch' configuration variable to

 remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into

 remote: error: its current branch; however, this is not recommended unless you
 remote: error: arranged to update its work tree to match what you pushed in some

 remote: error: other way.
 remote: error:
 remote: error: To squelch this message and still keep the default behaviour, set

 remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
 To c:/jGit
 ! [remote rejected] master -> master (branch is currently checked out)
 error: failed to push some refs to 'c:/gitRepository'

One solution is to run the following command:

git config receive.denyCurrentBranch ignore

After this it works, but I would like to know why I need to use this option. Is this the only option? What are the consequences of doing this?

What I would really like to do is create branches, merge them into the master branch and then push my changes to the server.

解决方案

The server where you are pushing to should use bare repository.

How to convert a normal Git repository to a bare one?

这篇关于在Git中使用receive.denyCurrentBranch有什么后果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆