简体   繁体   中英

remove git file from repository not having local copy

working with git is obvious when u have local copy of repository on disk but sometimes there is requirement to work only with specific file(s) from known address of repository.

So here it is: my target is to delete single file or known list of file in given repo - the hard part is that because of performance reasons i don't want to clone entire repository to disk. I'm using already bitbucket server api but it seems there is no way of doing it. Of course i want to be able to see this operation later in git as a commit.

All git mutable operations can only work on a working tree . So if you want to do a commit it needs to be applied to a working tree. Whether this one resides on your local machine or somewhere else is equal. But the git executable needs file system access to it. You won't come around this restriction. Even git commands that seem manipulate the repository directly (like --filter-branch) use a temporary working tree.

But you can speed up things when you use a shallow clone ( --depth 1 ) rather than a full clone. This significantly faster .

Note that you need a sufficiently recent git version for this to work. See also here: Better support for shallow clones in git 1.9


Another option is to create a service at the repository server that does the job for you. This is faster because the main traffic is now local . But of course using a third party git server like butbucket this is not an option.

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