From: "Jonas Bang" <email@jonasbang.dk>
To: <git@vger.kernel.org>
Subject: Git feature request: Option to force Git to abort a checkout if working directory is dirty (i.e. disregarding the check for conflicts)
Date: Thu, 27 Mar 2014 17:15:33 +0100 [thread overview]
Message-ID: <004d01cf49d7$c8b9cd90$5a2d68b0$@jonasbang.dk> (raw)
Hi Git developers,
This is my first Git feature request, I hope it wont get me hanged on the
gallows ;o)
*Git feature request:*
Add an option to Git config to configure the criteria for when a "git
checkout" should abort.
*Name proposal and options:*
checkout.clean false <default>
checkout.clean true
*False behavior:*
As is:
When doing a checkout then Git will check if your working directory is
dirty, and if so check if the checkout will result in any conflicts, and if
so abort the checkout with a message:
$ git checkout some_branch
error: Your local changes to the following files would be overwritten by
checkout:
some_file
Please, commit your changes or stash them before you can switch branches.
Aborting
If no conflicts then:
$ git checkout some_branch
M some_file
M some_other_file
Switched to branch 'some_branch'
I.e. it will only abort if there are conflicts.
*True behavior:*
When doing a checkout then Git will check if your working directory is dirty
(checking for both modified and added untracked files), and if so abort the
checkout with a message:
$ git checkout some_branch
error: Your working directory is not clean.
Please, commit your changes or stash them before you can switch branches.
Aborting
I.e. it will abort if working directory is dirty (checking for both modified
and added untracked files).
I.e. you can only do checkout if you get "nothing to commit, working
directory clean" when running "git status" (ignoring ignored files though).
*Usecase in short:*
If you use an IDE (like e.g. Eclipse) and do a checkout
of 'some_branch' with a dirty working directory which will not result in any
conflicts, then you will not be nicely notified (as you would in Git Bash)
that the changes you were working on in 'previous_branch' are still present
in your working directory after changing to 'some_branch'. I.e. when you
compile your code your uncommitted changes from 'previous_branch' are still
present in your working directory on 'some_branch'.
As I see it Git is extremely strong in context switching (i.e. working on
multiple issues on multiple branches), and I could see a use for a setting
which setup a strict check for if working directory is not clean
(disregarding the check for conflicts). This would mean that your changes
created while on branch #1 will not be carried over when changing to branch
#2, i.e. you will work strictly context based always.
*Usecase also described here:*
http://stackoverflow.com/questions/22609566/how-to-force-git-to-abort-a-chec
kout-if-working-directory-is-not-clean-i-e-dis
Br,
Jonas Bang Christensen
next reply other threads:[~2014-03-27 16:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-27 16:15 Jonas Bang [this message]
2014-03-27 17:46 ` Git feature request: Option to force Git to abort a checkout if working directory is dirty (i.e. disregarding the check for conflicts) Junio C Hamano
2014-03-29 11:49 ` Jonas Bang
2014-03-31 17:13 ` Junio C Hamano
2014-04-01 17:57 ` Jonas Bang
2014-04-02 17:55 ` Junio C Hamano
2014-04-03 18:42 ` Jonas Bang
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='004d01cf49d7$c8b9cd90$5a2d68b0$@jonasbang.dk' \
--to=email@jonasbang.dk \
--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).