File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -379,6 +379,23 @@ export default class ObsidianGit extends Plugin {
379
379
}
380
380
} ) ;
381
381
382
+ this . addCommand ( {
383
+ id : "discard-all" ,
384
+ name : "CAUTION: Discard all changes" ,
385
+ callback : async ( ) => {
386
+ if ( ! await this . isAllInitialized ( ) ) return false ;
387
+ const modal = new GeneralModal ( {
388
+ options : [ "NO" , "YES" ] ,
389
+ placeholder : "Do you want to discard all changes to tracked files? This action cannot be undone." ,
390
+ onlySelection : true
391
+ } ) ;
392
+ const shouldDiscardAll = await modal . open ( ) === "YES" ;
393
+ if ( shouldDiscardAll ) {
394
+ this . promiseQueue . addTask ( ( ) => this . discardAll ( ) ) ;
395
+ }
396
+ }
397
+ } ) ;
398
+
382
399
this . registerEvent (
383
400
this . app . workspace . on ( 'file-menu' , ( menu , file , source ) => {
384
401
this . handleFileMenu ( menu , file , source ) ;
@@ -1068,6 +1085,13 @@ export default class ObsidianGit extends Plugin {
1068
1085
}
1069
1086
}
1070
1087
1088
+ async discardAll ( ) {
1089
+ await this . gitManager . discardAll ( {
1090
+ status : this . cachedStatus
1091
+ } )
1092
+ new Notice ( 'All local changes have been discarded. New files remain untouched.' ) ;
1093
+ }
1094
+
1071
1095
clearAutos ( ) : void {
1072
1096
this . clearAutoBackup ( ) ;
1073
1097
this . clearAutoPush ( ) ;
You can’t perform that action at this time.
0 commit comments