search

Home  >  Q&A  >  body text

gitlab - What to do if a .git file is accidentally deleted from a git-hosted project

In the managed project directory, git -rf .git was executed incorrectly, resulting in the deletion of the .git file. Now the code cannot be submitted. What should I do?

怪我咯怪我咯2810 days ago945

reply all(4)I'll reply

  • 给我你的怀抱

    给我你的怀抱2017-05-02 09:41:45

    If you can’t find it in the recycle bin, there seems to be nothing you can do. This .git file is used to track warehouse changes.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-02 09:41:45

    Reswitch a directory git clone远程仓库 ,然后将现有仓库覆盖原有仓库后执行
    git add --> git commit -> git push

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-02 09:41:45

    I don’t know if you mean to delete the .git in the warehouse or delete your local .git.

    If you delete the .git of the warehouse, you can only rebuild it and git init --bare创建一个新的仓库,然后在本地 git add remote添加新仓库,然后 git push xxx xxx --force submit it.

    If only the .git of your local project is deleted, that’s easy to handle.
    Change the directory and clone it again, switch to the corresponding branch, and then copy all the files and directories in the deleted .git directory to overwrite the files in the new clone. Then commit and push.

    This is also an advantage of git distribution, you are not afraid of accidental deletion

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-02 09:41:45

    It doesn’t matter if you delete the local one. If there is a remote Repo, just clone it again.

    Moreover, if you execute git rm -rf .git, this will not delete your physical files.

    reply
    0
  • Cancelreply