简体   繁体   中英

Git not delete deleted file in local repo

I want to find out is it normal behaviour then you delete file in remote branch and use git pull to synchronize local branch,deleted file stil present in local repo?

For example:I delete file in remote repo. Local repo still have this delete files. Then i use git pull to fetch changes to local repo. I expect files which deleted in remote repo will be deleted in local. But this not gonna happened.

The local repository still has the files on disk, but those aren't being tracked anymore by git.

If you clone the repository in a new directory, you'll see that those files are in fact not present (as you'd expect).

If you want to automatically remove all non-tracked files from disk when you git pull , you can configure a post-merge hook to run a git clean command. To do this, create the following script named post-merge in the .git/hooks/ folder:

#!/bin/bash
git clean -f

Do note that this will delete every non-tracked file.

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