/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ファイルを削除したいかもしれません。現在、そのディレクトリに2つのgitリポジトリがあり、これが望むものであってもgitは気に入らないかもしれません。

おすすめ記事