git delete routine
2014-11-15
####git delete routine####
- Completely remove or delete a committed file in git repo require following steps. Even though the file gets removed with delete button option of OS. The committed files are still inside the git version control system, and it will make problem in uploading it into GitHub if it is large file size >100MB accidentally committed.
- First to list the files deleted in the OS but not in git system, based on this. The command for listing the deleted files
git ls-files --deleted
- The remove all the files in the deleted list from git system using same above command but with xarg command to loop the list and execute the git rm command as follows
git ls-files --deleted | xargs git rm
- From the same page to list all the files in git system also
git log --all --pretty=format: --name-only --diff-filter=D | sort -u
- The problem of the large file size of GitHub is still not addressed. The problem is complex and needs specific codes to do that such this.
- The easiest way forward in this situation is freshly clone the remote repository and add the new files in it and recommit. The issue here is losing of old commits.