Users not able to delete branches error -- packed-refs.new: File exists

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問


プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Fisheye および Crucible は除く

    

要約

When attempting to delete or create a branch an error occurs shows an error that states:

remote: error: unable to create file <bitbucketHome>/shared/data/repositories/<repoID>/./packed-refs.new: File exists

診断

This an example screen shot:
Screen Shot 2021-01-26 at 8.17.19 AM.png

原因

The file packed-refs.new exists in the git repository.  This file is used by git to provide a temporary file for the new pack and warn other git process that the pack is running. Git will create this file, packed-refs.new, put all of the references in this file, remove all of the loose references, them move the file to packed-refs.  The file format is <CommitHash>, then followed by the branch name.

If the normal process is interrupted, this file can be left around.  This can happen if a git pack-refs process was killed while packing.  

ソリューション

Remove the file.  Here is the process to remove the file without any further data loss.  This assumes that all Bitbucket Data Center Nodes have confirmed that the file is not being accessed.  Run this command on each Bitbucket Data Center Node.  No output means that the file is not being used if the full path of the file is like the above error.   OR do a rolling restart of each Bitbucket Data Center Node if you are unsure.

sudo lsof | grep "packed-refs.new"


packed-refs.new file is empty

It is safe to delete this file.

packed-refs.new  file is not empty

If you are unsure about any of these steps, please stop and contact support before step 9.

  1. Stop all Bitbucket Server or each Bitbucket Data Center Node.

  2. Move the file packed-refs.new to a temp directory:
    • mv <path>/packed-refs.new /tmp
  3. Copy the packed-refs file from the repository and check to see if there are any valid refs in packed-refs.new that are not in packed-refs
    • cp <pathToRepo>/packed-refs /tmp
      diff /tmp/packed-refs.new /tmp/packed-refs
  4. Make a copy of the git repository.
    • cp -r <path> /tmp
  5. For each hash in packed-refs.new make sure the reference is a valid commit.  Make a list of lines that have valid hashes.  If git log does not find a corresponding commit hash, you should not use that hash in the updated file. 
    • cd /tmp/<dir>/
      git log <hash>
  6. Add the missing lines to the original packed-refs file in /tmp.

  7. Copy the corrected packed-refs into the repository copy.
    • cp /tmp/packed-refs /tmp/<dir>/
  8. Run the pack refs and git fsck command to make sure the packed-refs file is valid.  If any errors, do not continue.  This step must pass to continue.
  9. Move the updated pack-refs file to the original repository.
    • cp /tmp/packed-refs <pathToRepo>/
  10. Start Bitbucket. 



最終更新日: 2021 年 1 月 29 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.