簡體   English   中英

從 .git 目錄恢復項目源代碼

[英]Recover project source code from .git directory

從包含對象和包文件的 .git 目錄中恢復源代碼的步驟是什么? 如何配置配置文件使其成為本地存儲庫?

如果這是一個工作目錄被刪除的普通存儲庫,只需在 .git 目錄的父目錄中檢出您想要的內容,例如git checkout master

如果它是一個裸存儲庫(即它是您的 git 服務器),則使用git clone <path to .git directory>將其克隆到另一個目錄中。

.git 存儲庫稱為裸存儲庫。 你可以用這個命令做你想做的事:

git --git-dir=path_to_bare_repo.git archive HEAD | tar -x -C path_to_destination_dir

如果您只想將裸存儲庫轉換為普通 git 存儲庫,只需按照此鏈接的幾個步驟操作: 如何將裸 git 存儲庫轉換為普通存儲庫(就地)?

操作非常簡單:

mkdir repo_dir
mv path_to_bare_repo.git repo_dir/.git
cd repo_dir/.git
git config --local --bool core.bare false

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM