git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Git feature request: Option to force Git to abort a checkout if working directory is dirty (i.e. disregarding the check for conflicts)
@ 2014-03-27 16:15 Jonas Bang
  2014-03-27 17:46 ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Jonas Bang @ 2014-03-27 16:15 UTC (permalink / raw)
  To: git

Hi Git developers, 

This is my first Git feature request, I hope it won’t 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

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

end of thread, other threads:[~2014-04-03 18:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-27 16:15 Git feature request: Option to force Git to abort a checkout if working directory is dirty (i.e. disregarding the check for conflicts) Jonas Bang
2014-03-27 17:46 ` 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

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).