grambank / grambank-analysed

3 stars 0 forks source link

Update .gitmodules #88

Closed HedvigS closed 1 year ago

HedvigS commented 1 year ago

Rejigging git submodule to grambank/grambank. Did I do it all good?

HedvigS commented 1 year ago

good idea @johenglisch !

johenglisch commented 1 year ago

Okay, I also set the submodule to the v1.0 commit (otherwise git will throw an error because it's still looking for a commit in glottobank/grambank-cldf).

Also, I think everybody who uses this repo should probably delete the folder for the submodule on their end and re-run git submodule update --init (or just re-clone grambank-analysed in its entirety -- that works too).

HedvigS commented 1 year ago

Okay, I also set the submodule to the v1.0 commit (otherwise git will throw an error because it's still looking for a commit in glottobank/grambank-cldf).

Also, I think everybody who uses this repo should probably delete the folder for the submodule on their end and re-run git submodule update --init (or just re-clone grambank-analysed in its entirety -- that works too).

Agreed. i did this: https://stackoverflow.com/questions/1260748/how-do-i-remove-a-submodule/36593218#36593218

johenglisch commented 1 year ago

Ah, okay -- deinit does look useful. I actually xkcd 1597'd it on my end. (^^)"

HedvigS commented 1 year ago

I am going to sent out instructions to the others.

Hello, 

This is a git service annoucement for all people who have clones of grambank/grambank-analysed. We are progressing in grambank release, and this necessitates a change in the submodule configuration. You will need to remove the current set-up for the dir called "grambank" inside the repos, and set-up a new one. Hopefully you don't have lingering changes in your local clone that you need to committ, if so manage that first and then proceed. Also make sure you're in the main branch.

Below are the relevant commands:

#fetch changes in origin to local clone
git fetch origin

#hard rest of main branch in local clone to main branch in origin
git reset --hard origin/master

# Remove the submodule entry from .git/config
git submodule deinit -f path/to/submodule

# Remove the submodule directory from the superproject's .git/modules directory
rm -rf .git/modules/path/to/submodule

# Remove the entry in .gitmodules and remove the submodule directory located at path/to/submodule
git rm -f path/to/submodule

#initialise submodules
git submodule update --init

Is that right?

johenglisch commented 1 year ago
  1. The master branch is called main here
  2. It might be better to use the real path names instead of path/to/thing
  3. These steps actually removes the grambank submodule entirely, so it needs to be submodule add'ed back

This is what worked on my machine:

git fetch origin
git reset --hard origin/main
git submodule deinit -f grambank
rm -rf .git/modules/grambank-cldf
git rm -f grambank
git submodule add https://github.com/grambank/grambank grambank
git submodule update --init
HedvigS commented 1 year ago
  1. The master branch is called main here
  2. It might be better to use the real path names instead of path/to/thing
  3. These steps actually removes the grambank submodule entirely, so it needs to be submodule add'ed back

This is what worked on my machine:

git fetch origin
git reset --hard origin/main
git submodule deinit -f grambank
rm -rf .git/modules/grambank-cldf
git rm -f grambank
git submodule add https://github.com/grambank/grambank grambank
git submodule update --init

after the rm, if we do a git reset --hard origin/main would that add the submodule to the config file again? because it's in main?

johenglisch commented 1 year ago

Not sure tbh, but I'd guess it would restore the .gitmodules file to its original form and point it back at the wrong repo.

johenglisch commented 1 year ago

Wait, you might be right -- it would set .gitmodules to the state of current master.

johenglisch commented 1 year ago

You can also just clone the repo into a temp folder and set it back to a pre-release state:

$ git clone git@github.com:grambank/grambank-analysed grambank-analysed-test
$ cd grambank-analysed-test
$ git checkout 202ad423
$ git submodules update --init

…and then just run the commands and see if anything goes up in flames.

HedvigS commented 1 year ago

haha so many options. let's give people something simple though, temp folders I think can get messy

HedvigS commented 1 year ago

How about we tell them to do:


#fetch changes in origin to local clone
git fetch origin

#hard rest of main branch in local clone to main branch in origin
git reset --hard origin/master

# Remove the submodule entry from .git/config
git submodule deinit -f path/to/submodule

# Remove the submodule directory from the superproject's .git/modules directory
rm -rf .git/modules/path/to/submodule

# Remove the entry in .gitmodules and remove the submodule directory located at path/to/submodule
git rm -f path/to/submodule

git reset --hard origin/master

#initialise submodules
git submodule update --init
johenglisch commented 1 year ago

The temp folder was only meant for us two on our computers to test these commands before telling others to run them.

The git reset --hard seemed to have worked on my end -- after setting the branch name to the correct one:

$ git reset --hard origin/master
fatal: ambiguous argument 'origin/master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
$ git reset --hard origin/main
HEAD is now at fcf971a Merge branch 'main' of https://github.com/grambank/grambank-analysed

But again, if you give these instructions to other people it might be better to use concrete path names (especially since path/to/submodule is called grambank in the repo and grambank-cldf in .git/modules/).

Also, I have no idea what happens to people who submoduled grambank-analysed with the --recursive flag. It's entirely possible that their set-up might break as well. In that case they might have to de-init and re-init that submodule (but I'm not entirely sure how reliably that works):

$ git submodule deinit grambank-analysed
$ git submodule update --init --recursive grambank-analysed
HedvigS commented 1 year ago

Got it!