Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The parameter -- prune should be disabled when using submodules. #1751

Open
ykla opened this issue May 25, 2024 · 0 comments
Open

The parameter -- prune should be disabled when using submodules. #1751

ykla opened this issue May 25, 2024 · 0 comments

Comments

@ykla
Copy link

ykla commented May 25, 2024

The parameter -- prune should be disabled when using submodules.

Now:

      - name: checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          submodules: recursive

But

/usr/bin/git -c protocol.version=2 fetch --prune --no-recurse-submodules origin +refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/tags/*
  From https://github.com/taophilosophy/taophilosophy.github.io
   * [new branch]      main       -> origin/main
  /usr/bin/git branch --list --remote origin/main
    origin/main
  /usr/bin/git rev-parse refs/remotes/origin/main
  d9845e8f081b7663cbd9d9b08c65b782bcc3d866
  /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules origin +29[50](https://github.com/taophilosophy/taophilosophy.github.io/actions/runs/9239015042/job/25417636393#step:4:55)cd9eb8ac895110a96f08b7d2ed5714ecfb56:refs/remotes/origin/main
  From https://github.com/taophilosophy/taophilosophy.github.io
   + d9845e8...2950cd9 2950cd9eb8ac89[51](https://github.com/taophilosophy/taophilosophy.github.io/actions/runs/9239015042/job/25417636393#step:4:56)10a96f08b7d2ed5714ecfb56 -> origin/main  (forced update)

Actually d9845e8f081b7663cbd9d9b08c65b782bcc3d866 is the latest commit from the main repository, It only updated the submodule with no other actions. However, the argument --prune will cause the latest commit to fall back.

And even if you use checkout alone, manually using the command git submodule update --init will not work. It will still force an overwrite. Unless you use git submodule update --init --remote, but that doesn't work as intended, because you want to get the version of the latest committed submodule in the current repository.

 /usr/bin/git -c protocol.version=2 fetch --prune --no-recurse-submodules origin +refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/tags/*
  From https://github.com/taophilosophy/taophilosophy.github.io
   * [new branch]      main       -> origin/main
  /usr/bin/git branch --list --remote origin/main
    origin/main
  /usr/bin/git rev-parse refs/remotes/origin/main
  a23b745c65a315b4a21cab68f0842075e51bfe8a
  /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules origin +a873319ea018754396a5760b996d411c0b0141ec:refs/remotes/origin/main
  From https://github.com/taophilosophy/taophilosophy.github.io
   + a23b745...a873319 a873319ea018754396a5760b996d411c0b0141ec -> origin/main  (forced update)

See also https://git-scm.com/book/en/v2/Git-Tools-Submodules :

So far, when we’ve run the git submodule update command to fetch changes from the submodule repositories, Git would get the changes and update the files in the subdirectory but will leave the sub-repository in what’s called a “detached HEAD” state. This means that there is no local working branch (like master, for example) tracking changes. With no working branch tracking changes, that means even if you commit changes to the submodule, those changes will quite possibly be lost the next time you run git submodule update. You have to do some extra steps if you want changes in a submodule to be tracked.

When using parameter -- prune, The detached HEAD will be removed which we just need.

@ykla ykla changed the title The parameter --no-recurse-submodules should be disabled when using submodules. The parameter -- prune should be disabled when using submodules. May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant