git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Integrating submodules with no side effects
@ 2016-10-18 19:35 Robert Dailey
  2016-10-18 21:17 ` Stefan Beller
  0 siblings, 1 reply; 8+ messages in thread
From: Robert Dailey @ 2016-10-18 19:35 UTC (permalink / raw)
  To: Git

Hello git experts,

I have in the past attempted to integrate submodules into my primary
repository using the same directory name. However, this has always
caused headache when going to and from branches that take you between
when this integration occurred and when it didn't. It's a bit hard to
explain. Basically, if I have a submodule "foo", and I delete that
submodule and physically add its files under the same directory "foo",
when I do a pull to get this change from another clone, it fails
saying:

error: The following untracked working tree files would be overwritten
by checkout:
        foo/somefile.txt
Please move or remove them before you switch branches.
Aborting
could not detach HEAD


Obviously, git can't delete the submodule because the files have also
been added directly. I don't think it is built to handle this
scenario. Here is the series of commands I ran to "integrate" the
submodule (replace the submodule with a directory containing the exact
contents of the submodule itself):

#!/usr/bin/env bash
mv "$1" "${1}_"
git submodule deinit "$1"
git rm "$1"
mv "${1}_" "$1"
git add "$1/**"

The above script is named git-integrate-submodule, I run it like so:

$ git integrate-submodule foo

Then I do:

$ git commit -m 'Integrated foo submodule'

Is there any way to make this work nicely? The only solution I've
found is to obviously rename the directory before adding the physical
files, for example name it foo1. Because they're different, they never
"clash".

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-10-25 15:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-18 19:35 Integrating submodules with no side effects Robert Dailey
2016-10-18 21:17 ` Stefan Beller
2016-10-19 13:27   ` Robert Dailey
2016-10-19 16:23     ` Stefan Beller
2016-10-19 19:19       ` Robert Dailey
2016-10-19 19:45         ` Stefan Beller
2016-10-19 19:51           ` Robert Dailey
2016-10-25 15:05             ` Robert Dailey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).