0

This is very close to both Is there a command to undo git init? and How to fully delete a git repository created with init? Unfortunately, the accepted answers do not fit well because I init'd my home directory. (I missed a cd, and then issued git init).

Now, when I try to clone at my home directory, git just hangs and then time's out:

$ git clone -v https://gtihub.com/weidai11/cryptopp cryptopp-docs
Cloning into 'cryptopp-docs'...
fatal: unable to access 'https://gtihub.com/weidai11/cryptopp/': Connection timed out after 300043 milliseconds

The web interface is fine during this timeout period. I can navigate the project, examine commits, etc. I can also clone the same repo from another machine.

I want to avoid blowing out my other configuration information housed in the ~/.git folder.

How do I fix a git init issued from the wrong directory without deleting the .git folder?


Here's what I am seeing in the home directory:

$ ls -Al | grep '.*git*'
drwxr-xr-x   10 jwalton  staff       340 Sep 11 18:51 .git
-rw-r--r--    1 jwalton  staff        83 Jun 16 03:29 .gitconfig

And git is showing a bunch of untracked files from the home directory:

$ cd ~
$ git status -s | wc -l
91
Community
  • 1
  • 1
jww
  • 97,681
  • 90
  • 411
  • 885
  • Have you done more than just `git init`? If you're cloning a repository then you must have committed something somewhere along the line. – Whymarrh Sep 13 '16 at 22:52
  • @Whymarrh - I may have; but I don't recall for sure. I was working too late into the night, and my mind was fairly dull (more dull than normal). – jww Sep 13 '16 at 22:53
  • 2
    Understood, though as it stands I think this question is a bit unclear. What is it that you're trying to fix and what errors are you seeing? If it's that you're running into an error when cloning a repository, I think that is unrelated to running `git init`. – Whymarrh Sep 13 '16 at 22:56
  • If the `.git` folder in your home directory was not supposed to be created there, why can't you just delete it? – Scott Weldon Sep 13 '16 at 23:00
  • @Whymarrh - OK, thanks. Let's handle the Git de-init without deleting the directory since the init was a mistake. The odd thing is, I can clone from other directories; just not my home directory. I've only noticed it today since today is the first try to clone from the home directory. I fat fingered the init two days ago. – jww Sep 13 '16 at 23:00
  • If you want to "de-init" the Git repository in your home directory, you will eventually need to delete the `.git` subdirectory. You can run `git status` in your home directory to see if there's anything uncommitted (and hopefully everything is). With any luck, `git status` will take a while to report that a lot of files are "untracked" and (closer to the beginning of its output) that you're at the initial commit. If that's the case, you can simply delete the `.git` directory. – Whymarrh Sep 13 '16 at 23:08
  • 2
    Also, no global state should be stored in that `.git` directory. I think you may be confusing it with your `.gitconfig` file. – Whymarrh Sep 13 '16 at 23:14
  • @Whymarrh - yes, that's the underlying concern - losing important information in a configuration file. I have to admit the [`git-confg`](https://git-scm.com/docs/git-config) man pages confused me more that I already am when it comes to git. There are too many `.git` folders, and too many `.gitconfig` files. – jww Sep 13 '16 at 23:38
  • @jww: Oh, but that is easy, actually. `.git` is the directory where there is the configuration of a repository, (file `.git/config` is the most interesting one). The user configuration file is `~/.gitconfig` (or `~/.config/git/config/` if you are an XDG fan). Lastly, the system configuration is `/etc/gitconfig`, but I've never seen that used. – rodrigo Sep 14 '16 at 00:05

0 Answers0