basically I'm trying to customise huggingface
's diffusers
library to suit my case. In order to do that, I've cloned the diffusers
library source code under my project folder.
So the directory structure is like
my_project
├── .venv
├── .git
├── my_root_src
│ ├── file_1.py
│ ├── file_2.py
├── diffusers # this one has become submodule
│ ├── .git
│ ├── some_file_I_need_to_customise.py
.
.
.
└── .gitignore
I need to customise the diffusers
source code.
The problem is,
diffusers
librarymy_project
repository
What kind of actions could I take?
(Updated) By the way, the main reason I didn't fork the repo in the first place is because I tried to follow the below link.
https://huggingface.co/docs/diffusers/en/installation#editable-install
You have two problems.
the modified diffusers code in my local repo, which is committed locally, and pushed to my github repo, does not appear when I've cloned my_project repo in another machine. The submodule appears to be empty.
When you clone a repository which contains a submodule, you must also initialize and fetch that submodule.
git submodule init
git submodule update
Or you can clone with git clone --recurse-submodules
.
See the Submodules section of the Pro Git book for more.
it seems like it doesn't match with my situation. git submodule init and git submodule update seem to fetch original diffusers commits, not my customised commits.
As with everything in Git, everything you do is local. That includes changes to your diffusers submodule. If you want those changes to be seen by others, they must be pushed to a server.
If you want to change the diffusers source code AND want those changes to appear when you clone my_project, you will need your own fork of diffusers to store your changes. A fork is where you maintain your own copy of the repository. You can make your own changes, and you can also update it from the original repository ("upstream").
diffusers is on Github so you can fork your own copy of the repository there. Then have your submodule in my_project point to your fork. Push your changes to your fork so they can be seen by your other clones.
You'll want to keep diffusers up to date with the original repository. Add it as a remote, fetch it, and merge the upstream's main branch into your local main branch.
git remote add upstream <url to original diffusers repo>
.git fetch upstream
.git merge upstream/main
Or you can use Github's syncing tool.
See Fork a repository and Synching a repository.