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.
CodePudding user response:
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.