I am new to Git.
I just installed Git (2.9.3) for Windows (10), then I opened git-bash and did a git clone <remoteURL>
. A new folder is created with the whole copy of the remote repository, which is good. But then I run a git status
and I get a ton of deleted
files (I suppose all the files that just got copied) ready to be committed
, and the three main folders under the repository folder are untracked
. The deleted
files actually exist on my drive though!
I am pretty sure my git status should be clean instead. What is happening?
This about deleted files didn't help (I didn't use checkout
), neither did this about untracked files (I'm not using Mac OS).
Even if a later commit deletes the file, the file will still be present in a git clone because a git clone contains the full history (because Git is a distributed version control system). This is what would allow you to retrieve the file by checking out a previous commit.
git clone is primarily used to point to an existing repo and make a clone or copy of that repo at in a new directory, at another location. The original repository can be located on the local filesystem or on remote machine accessible supported protocols. The git clone command copies an existing Git repository.
You can restore a deleted file from a Git repository using the git checkout command. If you do not know when a file was last deleted, you can use git rev-list to find the checksum of the commit in which that file was deleted. Then, you can check out that commit.
If you have deleted the file and already committed the changes, you need to use the ` git checkout` command to restore the file. First, you need to find out the checksum of the commit that deleted the file, and then check out the file from the previous commit.
I was retrieving a huge project with very long paths. I forgot to set up Git to use long paths:
git config --global core.longpaths true
After this, the cloning went fine and the status clean.
It sounds like you've somehow loaded an empty index. The normal way this happens in with the command git read-tree --empty
, but that's not something you usually use/know as a new user of git.
Perhaps something went wrong with the clone. It's shouldn't be difficult to fix though, just run
git reset
and the index should be restored to the contents of the latest commit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With