简体   繁体   中英

Git: Remove files after push

I have a local repository at my workstation and remote repository on server (phpfog.com). My application generates cache files and I want to delete them (on the remote) everytime someone pushes: is it possible and if so - how? FYI: These files are ignored using .gitignore (maybe there might be a way how to use this).

I've heard of git hooks but have little idea how to use them.

Thank you

Edit: I want to do git clean (remove untracked files) but on the remote and with every push. These files are generated by application and this cannot be solved by .gitignore-ing them (in fact they are gitignored).

I think post-receive hook is what you are looking for.

Just add a bash script to remote server which clean all cache file and specify it as post-receive hook. For more information look at http://book.git-scm.com/5_git_hooks.html

Why are people pushing files that are better ignored? Just git rm --cached them and commit and push. Make sure they are properly added to the .gitignore and it would make sure people are not accidentally adding these files again and pushing them.

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