git push fails :`check out branch : refs / heads / master 업데이트 거부
JBoss 구성에 대한 로컬 수정 사항을 git에 저장하고 싶습니다. 이를 위해 다음 구조를 설정했습니다.
lrwxrwxrwx 1 jboss jboss 19 Jan 24 11:53 current -> jboss-as-7.1.0.CR1b
drwxr-xr-x 11 jboss jboss 4096 Jan 24 12:13 jboss-as-7.1.0.CR1b
-rw-r--r-- 1 jboss jboss 108211143 Jan 23 16:02 jboss-as-7.1.0.CR1b.tar.gz
drwxr-xr-x 6 jboss jboss 4096 Jan 24 11:36 local
local
"원본"이 될 자식 저장소입니다. 아이디어는 업데이트가 제공 될 경우 JBoss 배포를 쉽게 업데이트 할 수 있기 때문에 원한다는 것입니다. 배포 된 JBoss 패키지에 대한 모든 로컬 수정 사항을 git에 저장하고 싶습니다.
그래서 현재 저는 이렇게합니다.
jboss@tpl0:~/jboss-as-7.1.0.CR1b$ git init
Initialized empty Git repository in /opt/jboss/jboss-as-7.1.0.CR1b/.git/
jboss@tpl0:~/jboss-as-7.1.0.CR1b$ git remote add origin ../local/
jboss@tpl0:~/jboss-as-7.1.0.CR1b$ git pull origin master
From ../local
* branch master -> FETCH_HEAD
지금까지 모든 로컬 수정이 내가 원하는 곳에 있습니다.
그러나 로컬 수정 사항이있는 저장소 local
로 다시 부싱 발생 오류가 발생합니다.
jboss@tpl0:~/jboss-as-7.1.0.CR1b$ vim standalone/configuration/standalone.xml
jboss@tpl0:~/jboss-as-7.1.0.CR1b$ git commit -a -m "renamed database to project2_core, to distinguish from other projects"
[master 3e54f34] renamed database to project2_core, to distinguish from other projects
Committer: jboss <jboss@tpl0.(none)>
1 files changed, 1 insertions(+), 1 deletions(-)
jboss@tpl0:~/jboss-as-7.1.0.CR1b$ git push origin master
Counting objects: 9, done.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (5/5), 447 bytes, done.
Total 5 (delta 3), reused 0 (delta 0)
Unpacking objects: 100% (5/5), 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 t
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing int
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 som
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, se
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To ../local/
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '../local/'
이것에 대해 무엇을 할 수 있습니까? 어떤 도움도 대단히 감사합니다!
편집하다
문제를 해결 한 작업은 다음과 가변합니다.
cd ~/current
git init
vim .gitignore # set up a basic .gitignore file
git add .gitignore
git commit -a -m "initial commit"
cd ~/local
git clone ~/current
git branch -m master current # rename master branch to 'current'
git branch repo
git checkout repo
이제 current
디렉토리 의 브랜치 ~/local
는 항상 최신 상태이지만 첵킹되지 않아서 밀어 넣을 수 있습니다.
원격 사이트의 마스터 분기가 체크 아웃됩니다. 원격 저장소에 액세스 할 수있는 경우 다른 브랜치를 체크 아웃 한 다음 저장소에서 푸시합니다.
푸시는 베어 리포지토리를 의미합니다. 베어 리포지토리가 아닌 경우에는 끌어 와야합니다.
어쨌든 이것을 강제하려면 오류 메시지에 나와있는대로 수행하고 receive.denyCurrentBranch를 무시하도록 설정할 수 있습니다. 푸시하고 실행하는 저장소 위치에 대한 SSH :
git config receive.denyCurrentBranch ignore
원본 (로컬) 저장소를 베어 저장소 (예 : git init --bare)로 생성하거나 마스터가 아닌 브랜치를 체크 아웃합니다.
또는,
원격 프로젝트를 초기화 할 때
git init --bare
나는 'local'에서 'current'로 밀기보다는 'current'의 'local'에서 당겨서이 문제를 해결했습니다.
나는 이것이 꽤 오래된 질문이라는 것을 알고 있지만 git init --bare를 사용한다면 'GIT_DIR ='을 조심하십시오. 푸시 후 repo를 체크 아웃하기 위해 후크를 사용하는 경우 베어 repo 후크에 대해 설정됩니다. 후크 루틴에서 'export GIT_DIR = .git'을 사용하여 가져 오는 저장소를 인식하도록합니다 ....
'ProgramingTip' 카테고리의 다른 글
Python : smtplib 모듈을 사용하여 이메일을 보낼 때 "제목"이 표시되지 않음 (0) | 2020.12.28 |
---|---|
"이름이"rabbit "인 노드가 이미 실행 중"이지만 " 'rabbit'노드에 수 없습니다." (0) | 2020.12.28 |
인앱 구매에서 가격 등급을 설명 수 없습니다. (0) | 2020.12.28 |
자바 펼쳐 루프 변수 범위 (0) | 2020.12.28 |
OSX 10.11 El Capitan에 virtualenvwrapper를 사용할 수 없습니다. (0) | 2020.12.28 |