2016-06-23 12 views
4

Bitbucketリポジトリのクローンを別のBitbucketリポジトリにミラーリングしたいとします。 私が行うシェルスクリプト、でこれを管理し、次のgitミラークローンからプルリクエストを除外する方法

私はのBitbucketは(ソースのBitbucket上で作成されている)プルリクエストをプッシュすることはできませんので、押して、次のエラーを取得しています今
git clone --mirror <sourceUrl> 
git remote set-url --push origin <targetUrl> 
git push --mirror 

remote: You are attempting to update refs that are reserved for Bitbucket's pull 
remote: request functionality. Bitbucket manages these refs automatically, and they may 
remote: not be updated by users. 
remote: 
remote: Rejected refs: 
remote:   refs/pull-requests/21/from 
remote:   refs/pull-requests/23/from 
remote:   refs/pull-requests/23/merge 
remote:   refs/pull-requests/24/from 
remote:   refs/pull-requests/24/merge 
To ... 
! [remote rejected] refs/pull-requests/21/from -> refs/pull-requests/21/from (pre-receive hook declined) 
! [remote rejected] refs/pull-requests/23/from -> refs/pull-requests/23/from (pre-receive hook declined) 
! [remote rejected] refs/pull-requests/23/merge -> refs/pull-requests/23/merge (pre-receive hook declined) 
! [remote rejected] refs/pull-requests/24/from -> refs/pull-requests/24/from (pre-receive hook declined) 
! [remote rejected] refs/pull-requests/24/merge -> refs/pull-requests/24/merge (pre-receive hook declined) 
error: failed to push some refs to '...' 

私は次の回避策をフェッチレフリーを適応させることによってhttp://christoph.ruegg.name/blog/git-howto-mirror-a-github-repository-without-pull-refs.htmlからのヒントで問題を解決しました。

私は新しい裸のリポジトリを作成し、設定に以下の方法を適応:

[core] 
    repositoryformatversion = 0 
    filemode = true 
    bare = true 
[remote "origin"] 
    fetch = +refs/heads/*:refs/heads/* 
    fetch = +refs/tags/*:refs/tags/* 
    url = <sourceUrl> 
    mirror = true 
    pushurl = <targetUrl> 

は、その後、私はGitのプルとGitのプッシュを実行し、すべてが正常です。

しかし、回避策は美しい解決策ではありません。なぜなら、空の裸のリポジトリを作成して上書きすることは奇妙なので、私は別の方法が欲しいからです。

質問:

  • は、私は「gitのクローン--config」とフェッチに必要な設定を追加することができますが、私はしても、元のfetch = +refs/*:refs/*コンフィギュレーションを削除することができます(gitのクローンを取り出して、これは初期だ実行する前に)」 git clone "コマンド?これにより、プルリクエストが最初にプルされるという問題が解決されます。
  • プルリクエスト後、プルリクエストをベアリポジトリから削除することはできますか?
  • プッシュリクエストをプッシュから除外することはできますか?
+0

これはローカルのビットバケットサーバですか、bitbucket.orgですか?私は後者がプルリクエストを引き出すことができるかどうか分からなかった。私は再現できません。 – tedder42

+0

ローカルのBitbucketサーバです。 –

+3

'git show-ref |カット-d '' -f2 | grep 'pull-request' | xargs -L1 git update-ref -d' – Ivan

答えて

5

Ivanに感謝します。

彼の命令は私の問題を解決しました。空のgrepsに反応するためにxargsに "-r"パラメータを追加するだけでした。

git show-ref | cut -d' ' -f2 | grep 'pull-request' | xargs -r -L1 git update-ref -d 
関連する問題