@@ -34,6 +34,7 @@ struct checkout_opts {
34
34
int force_detach ;
35
35
int writeout_stage ;
36
36
int writeout_error ;
37
+ int overwrite_ignore ;
37
38
38
39
/* not set by parse_options */
39
40
int branch_exists ;
@@ -409,9 +410,11 @@ static int merge_working_tree(struct checkout_opts *opts,
409
410
topts .gently = opts -> merge && old -> commit ;
410
411
topts .verbose_update = !opts -> quiet ;
411
412
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
+ }
415
418
tree = parse_tree_indirect (old -> commit ?
416
419
old -> commit -> object .sha1 :
417
420
EMPTY_TREE_SHA1_BIN );
@@ -934,6 +937,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
934
937
3 ),
935
938
OPT__FORCE (& opts .force , "force checkout (throw away local modifications)" ),
936
939
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)" ),
937
941
OPT_STRING (0 , "conflict" , & conflict_style , "style" ,
938
942
"conflict style (merge or diff3)" ),
939
943
OPT_BOOLEAN ('p' , "patch" , & patch_mode , "select hunks interactively" ),
@@ -945,6 +949,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
945
949
946
950
memset (& opts , 0 , sizeof (opts ));
947
951
memset (& new , 0 , sizeof (new ));
952
+ opts .overwrite_ignore = 1 ;
948
953
949
954
gitmodules_config ();
950
955
git_config (git_checkout_config , & opts );
0 commit comments