4
Ruby 레이크 태스크에서 일부 git 명령을 실행하는 동안 다음과 같은 문제가 발생했습니다 (bash없이 시도했습니다 - login -c 같은 결과를 얻는다). rake 태스크 내에서 git commit/push를 실행하는 방법
tmpid='TueJan26014125UTC2010'
cmd=["git add .",
"git commit -a -m \'Migrate nanoc3 co output to gh-pages #{tmpid}\'",
"git push --force origin gh-pages:gh-pages"
]
FileUtils.chdir @gh_pages_repo_path.to_s do
puts `pwd`
cmd.each do |cmdi|
puts "bash --login -c '#{cmdi}'"
res=Kernel.send(:`, "bash --login -c '#{cmdi}'")
puts res
end
end
내가이 출력 내가 모든 진행 bash 쉘 (konsole 바로)에서, 직후, 같은 명령을 실행하면 작업 디렉토리와 자식 푸시 잘
/home/mv/Documents/Workspaces/scar/ruby/scar/gh-pages
bash --login -c 'git add .'
bash --login -c 'git commit -a -m 'Migrate nanoc3 co output to gh-pages TueJan26014125UTC2010''
# On branch master
nothing to commit (working directory clean)
bash --login -c 'git push --force origin gh-pages:gh-pages'
error: src refspec gh-pages does not match any.
error: failed to push some refs to '[email protected]:hedgehog/scar.git'
To prevent you from losing history, non-fast-forward updates were rejected.
Merge the remote changes before pushing again.
See 'non-fast forward' section of 'git push --help' for details.
실패 나타냅니다
$ pushd /home/mv/Documents/Workspaces/scar/ruby/scar/gh-pages
/usr/src ~
$ git add .
$ git commit -a -m 'Migrate nanoc3 co output to gh-pages TueJan26014125UTC2010'
[gh-pages 14cbe34] Migrate nanoc3 co output to gh-pages TueJan26014125UTC2010
20 files changed, 100 insertions(+), 0 deletions(-)
$ git push --force origin gh-pages:gh-pages
Counting objects: 73, done.
Compressing objects: 100% (19/19), done.
Writing objects: 100% (38/38), 11.32 KiB, done.
Total 38 (delta 16), reused 0 (delta 0)
To [email protected]:hedgehog/scar.git
e0f0370..14cbe34 gh-pages -> gh-pages
통찰력을 주셔서 감사합니다.
불행히도 나는 쉘 명령을 사용하도록 루비 - 자식 너무이 오류를 보았다. 나는 아직 이것을 재현 할 시간이 없다. 그러나 이것은'git branch -a'와'git remote -v' 그리고'git checkout --track -b gh-pages origin/gh-pages를 실행함으로써 해결 된 것으로 보인다. ''git add' 전에. 그 후 위의 스크립트는 정상적으로 작동했습니다. 다시 말하지만, 아직 이것을 재현하지는 못했지만 github가 권장하는 gh-pages 하위 모듈 (예 :'rm .git/index') 등을 통해 얻을 수있는 상태와 관련이 있다고 생각합니다. – Hedgehog