2

I'm working with three branches

master
develop
feature-new-theme

Where feature-new-themeis a fork of develop.

In feature-new-theme I've added a new git submodule, called bootswatch, in protected/vendor/bootswatch dir.

It's all ok until this day.

I do a 'freezing commit': commit all files and subdir on feature-new-theme with message 'freeze'. So I've nothing untracked and nothing changed to commit.

Then I create an hotfix branch forking master.

git checkout master
git checkout -b hotfix-1.35.3 master

When I do a git status I see protected/vendor/bootswatch as untracked. Why ?!

So I created a .gitignore file into protected/vendor with this content

bootswatch/

I committed .gitignore into hotfix, but still I see the untracked dir doing a git status.

git status

# On branch hotfix-1.35.5
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       protected/vendor/bootswatch/

Why? How to switch from a branch with a submodule to another without it in the right git way?

Edit to reply common questions:

  • feature-new-theme has never been merged into master, because new feature will be merged only into develop, and only at release stage we create a release-x.y.z branch, do bump version, do small fixes and then merge release-x.y.z branch into master and into develop
  • the new submodule dir is untracked both on master and on hotfix branches
realtebo
  • 23,922
  • 37
  • 112
  • 189
  • Has `feature-new-theme` been merged into `master`? Is your submodule directory untracked on `master`, or only on the `hotfix` branch? – Craig Otis Sep 16 '14 at 10:37
  • @CraigOtis: i replied to you directly editing the question, see the edit at the end. And "thanks" for trying to help me – realtebo Sep 16 '14 at 10:44

1 Answers1

2

Well, as it is not required by master and hotfix, you can easily delete it.

It won't affect your feature-new-theme branch (if you submodule init/update after checking out back to it), it will clean up your current repo state.

Of course, it is not "the best conceivable way", because it requires to do non-git stuff. Of course you could try with git clean as well.

You can find complains on this behaviour all around the internet, like here or here.

This link gives some information: git clean is not removing a submodule added to a branch when switching branches

So the way with git clean would be:

git clean -f -f -d
Community
  • 1
  • 1
Piotr Zierhoffer
  • 5,005
  • 1
  • 38
  • 59