From: Stefan Beller <sbeller@google.com>
To: Yaroslav Halchenko <yoh@onerussian.com>
Cc: git <git@vger.kernel.org>
Subject: Re: [wishlist] git submodule update --reset-hard
Date: Thu, 6 Dec 2018 10:29:28 -0800 [thread overview]
Message-ID: <CAGZ79kY8uv8zDm3f8Jb6aC-nit7OZduixyOekGYWa_xnqFqw-w@mail.gmail.com> (raw)
In-Reply-To: <20181206173554.GH4633@hopa.kiewit.dartmouth.edu>
On Thu, Dec 6, 2018 at 10:02 AM Yaroslav Halchenko <yoh@onerussian.com> wrote:
>
> Dear Git Gurus,
>
> I wondered what would be your take on my wishlist request to add
> --reset-hard option, which would be very similar to regular "update" which
> checks out necessary commit, but I want it to remain in the branch.
What if the branch differs from the sha1 recorded in the superproject?
> Rationale: In DataLad we heavily rely on submodules, and we have established
> easy ways to do some manipulations across full hierarchies of them. E.g. a
> single command could introduce a good number of commits across deep hierarchy
> of submodules, e.g. while committing changes within deep submodule, while also
> doing all necessary commits in the repositories leading to that submodule so
> the entire tree of them stays in a "clean" state. The difficulty comes when
> there is a need to just "forget" some changes. The obvious way is to e.g.
>
> git reset --hard PREVIOUS_STATE
git reset --hard --recurse-submodules HEAD
would do the trick
> in the top level repository. But that leaves all the submodules now in
> the undesired state. If I do
undesirable in the sense of still having local changes (that is what
the above reset with `--recurse` would fix) or changed the branch
state? (i.e. is detached but was on a branch before?)
> git submodule update --recursive
>
> I would end up in the detached HEADs within submodules.
>
> What I want is to retain current branch they are at (or may be possible
> "were in"? reflog records might have that information)
So something like
git submodule foreach --recursive git reset --hard
?
You may be interested in
https://public-inbox.org/git/20180927221603.148025-1-sbeller@google.com/
which introduces a switch `submodule.repoLike [ = true]`, which
when set would not detach HEAD in submodules.
Can you say more about the first question above:
Would you typically have situations where the
submodule branch is out of sync with the superproject
and how do you deal with that?
Adding another mode to `git submodule update` sounds
reasonable to me, too.
Stefan
next prev parent reply other threads:[~2018-12-06 18:29 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-06 17:35 [wishlist] git submodule update --reset-hard Yaroslav Halchenko
2018-12-06 18:29 ` Stefan Beller [this message]
2018-12-06 21:24 ` Yaroslav Halchenko
2018-12-06 21:55 ` Stefan Beller
2018-12-07 1:22 ` Yaroslav Halchenko
2018-12-07 21:55 ` Stefan Beller
2018-12-08 2:15 ` Yaroslav Halchenko
2018-12-08 4:21 ` Yaroslav Halchenko
2018-12-10 18:58 ` Stefan Beller
2018-12-10 20:14 ` Yaroslav Halchenko
2018-12-11 4:08 ` [PATCH 1/2] submodule: Add --reset-hard option for git submodule update Yaroslav Halchenko
2018-12-11 4:08 ` [PATCH 2/2] RF+ENH(TST): compare the entire list of submodule status --recursive to stay intact Yaroslav Halchenko
2018-12-12 19:48 ` Stefan Beller
2018-12-13 16:42 ` Yaroslav O Halchenko
2018-12-13 20:44 ` Stefan Beller
2018-12-13 22:43 ` Yaroslav O Halchenko
2018-12-13 23:58 ` Stefan Beller
2018-12-14 4:22 ` Yaroslav O Halchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAGZ79kY8uv8zDm3f8Jb6aC-nit7OZduixyOekGYWa_xnqFqw-w@mail.gmail.com \
--to=sbeller@google.com \
--cc=git@vger.kernel.org \
--cc=yoh@onerussian.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).