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

Untracked files after switching from submodule to directory #624

Open
agners opened this issue Oct 26, 2021 · 1 comment
Open

Untracked files after switching from submodule to directory #624

agners opened this issue Oct 26, 2021 · 1 comment

Comments

@agners
Copy link

agners commented Oct 26, 2021

On a self-hosted runner, using actions/checkout@v2 on a repository which uses a submodule in directory x/, subsequently doesn't remove that submodule when it gets converted to a directory.

  1. Create repository with submodule in directory x/
  2. Use GitHub actions with actions/checkout@v2, observe that the main repository and directory x/ is correctly checked out
  3. Remove submodule x/ from repository, converting it to a regular "native" directory commited to the main repository
  4. Use GitHub actions with actions/checkout@v2. Directory x/ still contains the submodule. git seems not to cleanup/checkout the root repository folder x/. The directory contains untracked files.

The clean property is left default (which is true). It seems that git commands are not able to cleanup existing submodules in the working directory when moving from a branch with submodules to a branch without submodules.

It seems that the .git file of the submodules make git to stop recursing into those directories and not checking them out. Removing .git files of those removed submodules seems to help:

find ./ -name .git -type f -exec rm {} \;

This is particular annoying when moving from submodules to directory back and forth, e.g. when using the same runners for a stable branch and development branch.

agners added a commit to agners/operating-system that referenced this issue Oct 26, 2021
If a git submodule is converted to a regular git directory (e.g. when
moving from dev -> rel-6 branch), the directory is not properly cleaned
by the checkout action.

Remove the git submodule .git files which makes sure that git properly
reinitialize subdirectories, even if they have been a submodule before.

See also: actions/checkout#624
agners added a commit to home-assistant/operating-system that referenced this issue Oct 27, 2021
If a git submodule is converted to a regular git directory (e.g. when
moving from dev -> rel-6 branch), the directory is not properly cleaned
by the checkout action.

Remove the git submodule .git files which makes sure that git properly
reinitialize subdirectories, even if they have been a submodule before.

See also: actions/checkout#624
@agners
Copy link
Author

agners commented Mar 17, 2022

The work around removing the .git file only works when moving from git repo with submodule -> git repo without submodule. When a git repository with submodule is used, removing the .git file causes the submodule loosing track of what files belonging to the submodule. When the submodule is updated, all files which have been removed in that submodule will stay in the submodule directory (which can be problematic of course!).

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