From: Jason Holden <jason.k.holden@gmail.com>
To: git@vger.kernel.org
Cc: Jason Holden <jason.k.holden@gmail.com>
Subject: [PATCH 0/2] Don't delete untracked submodule's .git dirs by default
Date: Mon, 29 Jun 2009 22:10:43 -0400 [thread overview]
Message-ID: <1246327845-22718-1-git-send-email-jason.k.holden@gmail.com> (raw)
Git-clean is not safe when there is a submodule tracked in a local branch that
is not tracked in the mainline branch. Running git-clean from the mainline
branch when we have unpushed changes in a submodule tracked only in a local
branch can lose local changes to that submodule permanentely.
I have accidentally lost changes in this way when working with very
large projects where a git-clean is more reliable than a makefile's
"make clean".
By changing the default behavior of git-clean to not delete the .git
directories allows the history of the submodules to be recovered.
# Example of issue:
#
# Clone mainline project
git clone git://github.com/thoughtbot/paperclip.git
cd paperclip/
# Add a submodule not tracked by mainline
git checkout -b test_submodule_clean
git submodule add git://github.com/technoweenie/attachment_fu.git attachement_fu
git commit -m "add submodule"
# Make a modification to the submodule. Note that we haven't pushed the change
cd attachement_fu/
git checkout -b mod_readme_in_submodule
vi README
git add README
git commit -m "Small change in submodule"
# Go back to mainline's master branch and do a clean
cd ..
git checkout master
git clean -f -d
# Our change to the submodule, that was never pushed, is now gone forever
# because all the history stored in the submodule's .git direct is deleted.
# There is no recovering from this.
# This breaks the "git must be safe" rule, as we've lost potentially a lot of
# changes to any submodule projects that didn't get pushed yet. Solve
# this issue by not deleting any .git directories we come across during a
# git-clean, unless the "-m" option is passed to git-clean.
This is my first email submittal using git, so apologies in advance for any
formatting issues
Jason Holden (2):
Add option to not delete a .git directory in remove_dir_recursively()
Don't clean any untracked submodule's .git dir by default in
git-clean
Documentation/git-clean.txt | 6 +++++-
builtin-clean.c | 15 +++++++++++++--
builtin-clone.c | 4 ++--
dir.c | 17 +++++++++++++++--
dir.h | 2 +-
refs.c | 2 +-
transport.c | 4 ++--
7 files changed, 39 insertions(+), 11 deletions(-)
next reply other threads:[~2009-06-30 2:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-30 2:10 Jason Holden [this message]
2009-06-30 2:10 ` [PATCH 1/2] Add option to not delete a .git directory in remove_dir_recursively() Jason Holden
2009-06-30 2:10 ` [PATCH 2/2] Don't clean any untracked submodule's .git dir by default in git-clean Jason Holden
2009-06-30 6:07 ` Paolo Bonzini
2009-06-30 6:40 ` Johannes Sixt
2009-06-30 7:34 ` Junio C Hamano
2009-06-30 23:05 ` Junio C Hamano
2009-07-01 1:44 ` Jason Holden
2009-07-01 2:13 ` Junio C Hamano
2009-06-30 6:48 ` [PATCH 1/2] Add option to not delete a .git directory in remove_dir_recursively() Johannes Sixt
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=1246327845-22718-1-git-send-email-jason.k.holden@gmail.com \
--to=jason.k.holden@gmail.com \
--cc=git@vger.kernel.org \
/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).