简体   繁体   中英

How do I clone a GitHub repository and auto overwrite existing contents?

Greetings,

I recently set up a GitHub repository and installed Git on my system. Until now I have used AnkhSVN and Tortoise with Google code repositories and I am having some difficulties understanding some parts of Git.

For testing this system I tried deleting a couple of files from my project folder and used pull and clone in order to get those files back from the repo. The problems encountered were: "Already up-to-date." when using pull and "fatal: destination path 'Project' already exists and is not an empty directory." when using clone

I managed to get the latest files by deleting the entire folder and using clone. Is there a way for clone to automatically overwrite any existing contents in the directory?

Cheers

Git has the full history locally. You need not pull or clone to get the files back. As it sounds like you haven't committed the deletions, git reset --hard is one of the standard recommended ways to get them back. This just restores the working directory (and index of "staged changes to be committed") to the revision given, which defaults to "HEAD".

git checkout -f <branchname> should also work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM