Skip to content

Commit 5785f19

Browse files
elishowkstevhliuosanseviero
authored
Add how-to fork and rebase a fork (#370)
Co-authored-by: Steven Liu <[email protected]> Co-authored-by: Omar Sanseviero <[email protected]>
1 parent 07b0ad0 commit 5785f19

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

docs/hub/model-repos.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,62 @@ $$
142142

143143
$$ E=mc^2 $$
144144

145+
### How can I fork or rebase a repository with LFS pointers?
146+
147+
When you want to fork or [rebase](https://git-scm.com/docs/git-rebase) a repository with [LFS](https://git-lfs.github.com/) files (all files over 20MB are stored as such), you cannot use the usual Git approach since you need to be careful to not break the LFS pointers. Forking can take time depending on your bandwidth, because you will have to fetch an re-upload all the LFS files in your fork.
148+
149+
For example, say you have an upstream repository, **upstream**, and you just created your own repository on the Hub which is **myfork** in this example.
150+
151+
1. Create a destination repository (e.g. **myfork**) in https://huggingface.co
152+
153+
2. Clone your fork repository
154+
155+
```
156+
git lfs clone https://huggingface.co/me/myfork.git
157+
```
158+
159+
3. Fetch non LFS files
160+
161+
```
162+
cd myfork
163+
git lfs install --skip-smudge --local # affects only this clone
164+
git remote add upstream https://huggingface.co/friend/upstream.git
165+
git fetch upstream
166+
```
167+
168+
4. Fetch large files. This can take some time depending on your download bandwidth
169+
170+
```
171+
git lfs fetch --all upstream # this can take time depending on your download bandwidth
172+
```
173+
174+
4.a. If you want to override completely the fork history (which should only have an initial commit), run:
175+
176+
```
177+
git reset --hard upstream/main
178+
```
179+
180+
4.b. If you want to rebase instead of overriding, run the following command and solve any conflicts
181+
182+
```
183+
git rebase upstream/main
184+
```
185+
186+
5. Prepare your LFS files to push
187+
188+
```
189+
git lfs install --force --local # this reinstalls the LFS hooks
190+
huggingface-cli lfs-enable-largefiles . # needed if some files are bigger than 5Gb
191+
```
192+
193+
6. And finally push
194+
195+
```
196+
git push --force origin main # this can take time depending on your upload bandwidth
197+
```
198+
199+
Now you have your own fork or rebased repo in the Hub!
200+
145201
## List of license identifiers
146202
147203
Fullname | License identifier (to use in model card)

0 commit comments

Comments
 (0)