简体   繁体   中英

How do I unstage/delete files that have been deleted in the remote Git repo?

I have seen multiple questions about how to remove file that have been deleted locally from the remote repo, but my question is the reverse. Some files were moved/deleted in the remote repo, I want to delete the corresponding files from my local repo too. How do I do this?

Eg:

My root has directories foo , bar and baz . A remote commit moved bar and baz to a new directory archive . Now when I pull, I have foo , archive (with the two new directories under it), bar and baz .

Try

git fetch origin
git reset --hard origin/master

Assuming you're in the origin branch and want to sync with master

Use git clean to remove untracked directories, I believe git pull will delete files but not empty directories.

Try:

git clean -fd

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