0

My goal is to add the k3s-ansible repo as submodule, into my repo. Since k3s-ansible is an example repo, several files will require edits. Ideally, my main branch will contain k3s-ansible repo with all the customized files, while a k3s-ansible branch will allow me to update any submodule changes, then merge them into my main branch.

I'm not sure what is the correct way to achieve this.

Adding the submodule, into k3s-ansible branch:

$ git checkout -b k3s-ansible
$ git submodule add https://github.com/k3s-io/k3s-ansible.git k3s-ansible
$ git submodule update --init --recursive

Example of sample directory, which will be named cluster in my main branch. In this example, the content will not create any collisions with original repo, since I use a different directory name. Another example would be site.yml, which will have a different content in my main branch.

The part I'm missing is how to "import" the submodule changes from k3s-ansible branch into main branch, without changing any customized files or directories. Basically, I would need to ignore certain files or directories to be updated into main branch.

Please let me know the recommended approach for my use case, thank you.

Floren
  • 113
  • 11
  • 1) You want to update files in the superproject by files in the submodule, but submodules are set up in a separate subdirectory (maybe it could be solved by https://stackoverflow.com/q/5232829/14967413, but it is not typical). 2) I believe you can't "import" submodule changes from `k2s-ansible` branch to `master`. They are both you superproject's branches. Your submodule on the other hand has its own branch, which is independent on current superproject's branch. – user14967413 Jan 24 '23 at 10:21

0 Answers0