@@ -34,6 +34,7 @@ struct checkout_opts {
3434 int force_detach ;
3535 int writeout_stage ;
3636 int writeout_error ;
37+ int overwrite_ignore ;
3738
3839 /* not set by parse_options */
3940 int branch_exists ;
@@ -409,9 +410,11 @@ static int merge_working_tree(struct checkout_opts *opts,
409410 topts .gently = opts -> merge && old -> commit ;
410411 topts .verbose_update = !opts -> quiet ;
411412 topts .fn = twoway_merge ;
412- topts .dir = xcalloc (1 , sizeof (* topts .dir ));
413- topts .dir -> flags |= DIR_SHOW_IGNORED ;
414- setup_standard_excludes (topts .dir );
413+ if (opts -> overwrite_ignore ) {
414+ topts .dir = xcalloc (1 , sizeof (* topts .dir ));
415+ topts .dir -> flags |= DIR_SHOW_IGNORED ;
416+ setup_standard_excludes (topts .dir );
417+ }
415418 tree = parse_tree_indirect (old -> commit ?
416419 old -> commit -> object .sha1 :
417420 EMPTY_TREE_SHA1_BIN );
@@ -934,6 +937,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
934937 3 ),
935938 OPT__FORCE (& opts .force , "force checkout (throw away local modifications)" ),
936939 OPT_BOOLEAN ('m' , "merge" , & opts .merge , "perform a 3-way merge with the new branch" ),
940+ OPT_BOOLEAN (0 , "overwrite-ignore" , & opts .overwrite_ignore , "update ignored files (default)" ),
937941 OPT_STRING (0 , "conflict" , & conflict_style , "style" ,
938942 "conflict style (merge or diff3)" ),
939943 OPT_BOOLEAN ('p' , "patch" , & patch_mode , "select hunks interactively" ),
@@ -945,6 +949,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
945949
946950 memset (& opts , 0 , sizeof (opts ));
947951 memset (& new , 0 , sizeof (new ));
952+ opts .overwrite_ignore = 1 ;
948953
949954 gitmodules_config ();
950955 git_config (git_checkout_config , & opts );
0 commit comments