Git feature request: Option to force Git to abort a checkout if working directory is dirty (i.e. disregarding the check for conflicts)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]