How to “fork” Huggingface Repo?

A simle guide to reach a fork-like method on huggingface

Nicola Landro
1 min readMay 1, 2024

Huggingface do not have any fork methods so we must use normal git technique.

Create your repo and clone it.

git clone <repo-url>

Now add the repo to fork:

git remote add upstream <forked-url>

Pull the main, resolve conficts on .gitattributes accepting theirs (not ours) and push to your origin.

# Pull the main
git pull upstream main --allow-unrelated-histories --no-rebase

# show conflict, if any you will see in red
git status
# resolve conflicts, if the file is .gitattributes (in spaces maybe the README.md can be another conflict)
git checkout --theirs .gitattributes
git add .
git commit -m "merged"

# push
git push origin main

This procedure can be repeted each time we want to reallign with upstream, but the conflict to resolve must be more complicated if the two repo diverge a lot.

--

--

Nicola Landro

Linux user and Open Source fun. Deep learning PhD. , Full stack web developer, Mobile developer, cloud engineer and Musitian.