简体   繁体   中英

What is the workflow for Git LFS with forks?

I've introduced Git LFS into one of my repositories on bitbucket.org. Users that fork this repository can't push to their forks because there is no space for LFS files there. My understanding also is that when you fork a repository there, the LFS files are not copied.

Does using Git LFS with Bitbucket mean that forking isn't possible or at least usable? Or is there a special workflow/configuration for Git that can assist here?

Note that in my case, I use forks mostly as a way to persist work upstream that isn't ready to be seen by the rest of my team yet. For example, I'll push my incomplete work there so I can resume in a different physical location. Once I'm done, I publish my work to origin for the rest of the team to see.

This is a known issue, see current limitations for Git LFS with Bitbucket . I also hope Bitbucket (and Github!) is going to improve this.

Consequences:

  • LFS files must be synced between the fork and the upstream repo manually
  • Forks will also use significant Large File Storage space, not just the upstream (there is a free storage quota - but after that is exhausted you will have to pay for each fork, ouch! )
  • To copy LFS files back from the fork to the upstream, you will either need write access to the upstream repo or the upstream owner has to do it himself

How to sync the LFS files:

  1. Cloning the fork repo for the very first time - it does not have any LFS files copied yet, so you must clone it without the LFS files (otherwise cloning would fail)
export GIT_LFS_SKIP_SMUDGE=y
git clone <address of your fork>
  1. Synchronizing upstream -> fork (copying LFS files to your fork) - initially and each time you git fetch the upstream
git lfs fetch --all <upstream>
git lfs push --all <fork>
  1. Synchronizing fork -> upstream (only the current branch) - each time after your PR got merged
git lfs fetch <fork>
git lfs push <upstream>

If there is a better workflow than this, please let me know. This is a serious limitation of the Bitbucket LFS handling.

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