/home/user 디렉토리에 무엇을 했나요?

/home/user 디렉토리에 무엇을 했나요?

.git다른 위치에 있는 파일로 기본 git 저장소를 초기화할 계획입니다 . 그런 다음 어떻게 든 내 /home/<user>/디렉토리 등을 삭제했습니다 . 이것이 내가 한 일입니다:

$ cd /var/www/html/

$ mkdir web-test

$ cd ~/

그 안에 있는 폴더를 삭제해봤는데

$ rm foo.git -r

( -r디렉토리 뒤에 넣는 것이 잘못된 건가요?)

$ git init --separate-git-dir /var/www/html/web-test/ --bare

(파일을 넣을 폴더를 만드는 것을 잊었다는 것을 깨달았습니다 .git)

$ ls -a
.     .bash_history  .bash_profile  branches  description   HEAD     info
..    .kshrc         refs           .viminfo  .bash_logout  .bashrc  config
.git  hooks          .ipython       objects   .ssh

$ ls ~/ -a
ls: cannot access /home/<user>/: Not a directory

$ echo $PWD
/home/<user>

$ ls /var/www/html/web-test/ -a
.     .bash_history  .bash_profile  branches  description   HEAD     info
..    .kshrc         refs           .viminfo  .bash_logout  .bashrc  config
.git  hooks          .ipython       objects   .ssh

$ file ~
/home/<user>: ASCII text

누군가 내가 무엇을 했는지 말해 줄 수 있나요?

답변1

홈 디렉토리가 이동되었으며 /var/www/html/web-test/데이터 손실 없이 홈 디렉토리를 복원할 수 있습니다.


현재 디렉터리는 (아마도 ~) 이동되었으며 /var/www/html/web-test/그 안에 기본 git 저장소("refs" 및 "objects" 디렉터리 등)가 생성되었습니다. git이 따라갈 수 있는 위치에 텍스트 파일(예: 인간 심볼릭 링크)이 생성되었습니다.

gitdir: /var/www/html/web-test/

이것은기록된 행동git init --separate-git-dir:

   --separate-git-dir=<git dir>
       Instead of initializing the repository as a directory to either
       $GIT_DIR or ./.git/, create a text file there containing the path
       to the actual repository. This file acts as filesystem-agnostic Git
       symbolic link to the repository.

       If this is reinitialization, the repository will be moved to the
       specified path.

여기서 마지막 단락이 가장 중요합니다. 경로를 지정하지 않으면 기본적으로 해당 저장소는 에 있습니다 .. 시작하기 전에 몇 가지 힌트를 얻을 수 있다면 좋을 것입니다.

텍스트 파일을 삭제 rm ~하고( ) 디렉터리를 뒤로 이동하면( mv /var/www/html/web-test ~) 모든 것이 잘 됩니다.

나중에 git 파일을 삭제하고 싶을 수도 있습니다. 현재 해당 디렉토리에 두 개의 git 저장소가 있으며 이것이 원하는 것일지라도 git이 마음에 들지 않을 수 있습니다.

관련 정보