-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathcommands.json
More file actions
803 lines (801 loc) · 26.1 KB
/
commands.json
File metadata and controls
803 lines (801 loc) · 26.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
{
"commands": [
{
"command": "change author",
"description": "Change wrong name and email in last commit",
"mappedCommand": [
{
"command": "git",
"arguments": "commit --amend --author \"{{name}} <{{email}}>\""
}
],
"options": [
{
"name": "email",
"settings": {
"describe": "new email",
"required": true
}
},
{
"name": "name",
"settings": {
"describe": "new author name",
"required": true
}
}
]
},
{
"command": "show last commit",
"description": "What did I just commit?",
"mappedCommand": [
{
"command": "git",
"arguments": "log -n1 -p"
}
],
"options": []
},
{
"command": "remove last commit",
"description": "Delete or remove last commit",
"mappedCommand": [
{
"command": "git",
"arguments": "reset HEAD^ --hard"
},
{
"command": "git",
"arguments": "commit --amend"}
],
"options": []
},
{
"command": "remove file",
"description": "Remove a file from the previous commit. \nThis is particularly useful when you have an open patch and you have committed an unnecessary file, and need to force push to update the patch on a remote.",
"mappedCommand": [
{
"command": "git",
"arguments": "rm --cached {{{myfile}}}"
},
{
"command": "git",
"arguments": "commit --amend --no-edit"
}
],
"options": [
{
"name": "myfile",
"settings": {
"describe": "file name",
"required": true
}
}
]
},
{
"command": "remove changes for a file",
"description": "In order to remove changes for a file from the previous commit \nThe commit message is keeped unchanged.",
"mappedCommand": [
{ "command": "git","arguments": "checkout HEAD^ {{{myfile}}}"},
{ "command": "git","arguments": "add {{{myfile}}}"},
{ "command": "git","arguments": "commit --amend --no-edit"}
],
"options": [
{
"name": "myfile",
"settings": {
"describe": "file name",
"required": true
}
}
]
},
{
"command": "remove commit",
"description": "Reset Git to the state it was in before you made your last commit (while keeping your staged changes).",
"mappedCommand": [
{ "command": "git","arguments": "reset --soft HEAD@{1}"}
],
"options": []
},
{
"command": "remove arbitrary commit",
"description": "it will irreversibly change your history, and mess up the history of anyone else who had already pulled from the repository. In short, if you're not sure, you should never do this, ever.\nDo an interactive rebase instead and remove the line(s) corresponding to commit(s) you want to see removed",
"mappedCommand": [
{ "command": "git","arguments": "rebase --onto SHA1_OF_BAD_COMMIT^ SHA1_OF_BAD_COMMIT"},
{ "command": "git","arguments": "push --force-with-lease [remote] [branch]"}
],
"options": [{
"name": "remote",
"settings": {
"describe": "remote name",
"required": true
}
},
{
"name": "branch",
"settings": {
"describe": "branch name",
"required": true
}
}]
},
{
"command": "remove pushed commit",
"description": "Remove last commit. \nIf you need to delete pushed commits, you can use the following. However, it will irreversibly change your history, and mess up the history of anyone else who had already pulled from the repository. In short, if you're not sure, you should never do this, ever.",
"mappedCommand": [
{ "command": "git","arguments": "reset HEAD^ --hard"},
{ "command": "git","arguments": "push --force-with-lease"}
],
"options": [
{
"name": "remote",
"settings": {
"describe": "remote name",
"required": true
}
},
{
"name": "branch",
"settings": {
"describe": "branch name",
"required": true
}
}
]
},
{
"command": "push rejected commit",
"description": "push my amended commit to a remote that was rejected with an error message.\nIn general, avoid force pushing. It is best to create and push a new commit rather than force-pushing the amended commit as it will cause conflicts in the source history for any other developer who has interacted with the branch in question or any child branches.",
"mappedCommand": [
{ "command": "git","arguments": "push origin {{{branch}}} --force-with-lease"}
],
"options": [
{
"name": "branch",
"settings": {
"describe": "branch name",
"required": true
}
}
]
},
{
"command": "undo hard reset",
"description": "if you accidentally did a hard reset, and want the changes back.",
"mappedCommand": [
{ "command": "git","arguments": "reflog"}
],
"options": []
},
{
"command": "commit staged changes",
"description": "add staged changes to the previous commit.",
"mappedCommand": [
{ "command": "git","arguments": "commit --amend"}
],
"options": []
},
{
"command": "reset added files",
"description": "Reset added files.",
"mappedCommand": [
{ "command": "git","arguments": "reset HEAD"}
],
"options": []
},
{
"command": "reset added file",
"description": "Reset added file.",
"mappedCommand": [
{ "command": "git","arguments": "reset HEAD {{{myfile}}}"}
],
"options": [{
"name": "myfile",
"settings": {
"describe": "file name",
"required": true
}
}]
},
{
"command": "stage unstaged and unstage staged edits",
"description": "Stage unstaged edits, and unstage staged edits.",
"mappedCommand": [
{ "command": "git","arguments": "stash -k"},
{ "command": "git","arguments": "reset --hard"},
{ "command": "git","arguments": "stash pop"},
{ "command": "git","arguments": "add -A"}
],
"options": []
},
{
"command": "move edits to branch",
"description": "Move unstaged edits to a new branch.",
"mappedCommand": [
{ "command": "git","arguments": "checkout -b {{{branch}}}"}
],
"options": [{
"name": "branch",
"settings": {
"describe": "branch name",
"required": false
}
}]
},
{
"command": "move edits to existing branch",
"description": "Move my unstaged edits to a different, existing branch.",
"mappedCommand": [
{ "command": "git","arguments": "stash"},
{ "command": "git","arguments": "checkout -b {{{branch}}}"},
{ "command": "git","arguments": "stash pop"}
],
"options": [{
"name": "branch",
"settings": {
"describe": "branch name",
"required": true
}
}]
},
{
"command": "discard changes",
"description": "Discard my local uncommitted changes (staged and unstaged).",
"mappedCommand": [
{ "command": "git","arguments": "reset --hard"}
],
"options": []
},
{
"command": "undo add",
"description": "Unstage all files you might have staged with git add.",
"mappedCommand": [
{ "command": "git","arguments": "reset"}
],
"options": []
},
{
"command": "revert",
"description": "Revert all local uncommitted changes (should be executed in repo root).",
"mappedCommand": [
{ "command": "git","arguments": "checkout ."}
],
"options": []
},
{
"command": "revert file",
"description": "Revert uncommitted changes to a particular file or directory.",
"mappedCommand": [
{ "command": "git","arguments": "checkout {{{myfile}}}"}
],
"options": [{
"name": "myfile",
"settings": {
"describe": "file name",
"required": true
}
}]
},
{
"command": "revert all",
"description": "Another way to revert all uncommitted changes (longer to type, but works from any subdirectory).",
"mappedCommand": [
{ "command": "git","arguments": "reset --hard HEAD"}
],
"options": []
},
{
"command": "remove untracked files",
"description": "Remove all local untracked files, so only files tracked by Git remain.",
"mappedCommand": [
{ "command": "git","arguments": "clean -fdx"}
],
"options": []
},
{
"command": "discard specific unstaged changes",
"description": "Get rid of some, but not all changes in your working copy (interactively).\nCheckout undesired changes, keep good changes.\nAnswer y to all of the snippets you want to drop",
"mappedCommand": [
{ "command": "git","arguments": "checkout -p"}
],
"options": []
},
{
"command": "reapply specific unstaged changes",
"description": "Another strategy to discard specific changes involves using stash. Stash all the good changes, reset working copy, and reapply good changes",
"mappedCommand": [
{ "command": "git","arguments": "stash -p"},
{ "command": "git","arguments": "reset --hard"},
{ "command": "git","arguments": "stash pop"}
],
"options": []
},
{
"command": "discard specific unstaged files",
"description": "When you want to get rid of one specific file in your working copy.",
"mappedCommand": [
{ "command": "git","arguments": "checkout {{{myfile}}}"}
],
"options": [{
"name": "myfile",
"settings": {
"describe": "file name",
"required": true
}
}]
},
{
"command": "create branch from commit",
"description": "Create a branch from a commit.",
"mappedCommand": [
{ "command": "git","arguments": "checkout -b {{{branch}}} {{{commit}}}"}
],
"options": [{
"name": "branch",
"settings": {
"describe": "branch name",
"required": true
}
},{
"name": "commit",
"settings": {
"describe": "SHA1 of commit",
"required": true
}
}]
},
{
"command": "reset branch to commit",
"description": "Simply reset your branch back to the desired commit pulled from/into the wrong branch.\nUse 'git reflog' first to see where your HEAD pointed before the bad pull",
"mappedCommand": [
{ "command": "git","arguments": "reset --hard {{{commit}}}"}
],
"options": [{
"name": "commit",
"settings": {
"describe": "SHA1 of commit",
"required": true
}
}]
},
{
"command": "reset to branch",
"description": "Discard local commits so my branch is the same as one on the server",
"mappedCommand": [
{ "command": "git","arguments": "reset --hard origin/{{{branch}}}"}
],
"options": [{
"name": "branch",
"settings": {
"describe": "Name of origin branch",
"required": true
}
}]
},
{
"command": "move changes to branch",
"description": "Move wrongly committed changes to a new branch.\n First find out what the SHA1 of commit hash you want to set your master branch with `git log`",
"mappedCommand": [
{ "command": "git","arguments": "reset branch {{{branch}}}"},
{ "command": "git","arguments": "reset --hard HEAD^"},
{ "command": "git","arguments": "reset --hard {{{commit}}}"},
{ "command": "git","arguments": "checkout {{{branch}}}"}
],
"options": [{
"name": "branch",
"settings": {
"describe": "Name of origin branch",
"required": true
}
},{
"name": "commit",
"settings": {
"describe": "SHA1 of commit",
"required": true
}
}]
},
{
"command": "delete deleted local branches",
"description": "Delete local branches that were deleted upstream (remote).",
"mappedCommand": [
{ "command": "git","arguments": "fetch -p upstream"}
],
"options": []
},
{
"command": "delete remote branch",
"description": "Delete a remote branch",
"mappedCommand": [
{ "command": "git","arguments": "push origin --delete {{{branch}}}"}
],
"options": [{
"name": "branch",
"settings": {
"describe": "Name of branch",
"required": true
}
}]
},
{
"command": "delete local not been merged branch",
"description": "Delete a local branch that has not been merged to the current branch or an upstream",
"mappedCommand": [
{ "command": "git","arguments": "branch -D {{{branch}}}"}
],
"options": [{
"name": "branch",
"settings": {
"describe": "Name of branch",
"required": true
}
}]
},
{
"command": "rename current branch",
"description": "Rename the current (local) branch",
"mappedCommand": [
{ "command": "git","arguments": "branch -m {{{branch}}}"}
],
"options": [{
"name": "branch",
"settings": {
"describe": "New name of branch",
"required": true
}
}]
},
{
"command": "rename branch",
"description": "Rename a different (local) branch",
"mappedCommand": [
{ "command": "git","arguments": "branch -m {{{old-name}}} {{{new-name}}}"}
],
"options": [{
"name": "old-name",
"settings": {
"describe": "Current name of branch",
"required": true
}
},{
"name": "new-name",
"settings": {
"describe": "New name of branch",
"required": true
}
}]
},
{
"command": "create remote branch",
"description": "Create a new remote branch from current local one",
"mappedCommand": [
{ "command": "git","arguments": "push {{{remote}}} {{{branch}}}"}
],
"options": [{
"name": "remote",
"settings": {
"describe": "Remote name",
"required": true
}
},{
"name": "branch",
"settings": {
"describe": "New remote branch name",
"required": true
}
}]
},
{
"command": "set remote branch as upstream",
"description": "Set a remote branch as the upstream for a local branch",
"mappedCommand": [
{ "command": "git","arguments": "branch --set-upstream-to {{{remote}}}/{{{branch}}}"}
],
"options": [{
"name": "remote",
"settings": {
"describe": "Remote name",
"required": true
}
},{
"name": "branch",
"settings": {
"describe": "New remote branch name",
"required": true
}
}]
},
{
"command": "set head to track default remote branch",
"description": "By checking your remote branches, you can see which remote branch your HEAD is tracking. \nIn some cases, this is not the desired branch.",
"mappedCommand": [
{ "command": "git","arguments": "branch -rr origin/HEAD -> origin/gh-pages origin/master"}
],
"options": []
},
{
"command": "track remote master",
"description": "Change origin/HEAD to track origin/master branch",
"mappedCommand": [
{ "command": "git","arguments": "remote set-head origin --auto origin/HEAD"}
],
"options": []
},
{
"command": "undo rebase",
"description": "You may have merged or rebased your current branch with a wrong branch, or you can't figure it out or finish the rebase/merge process. Git saves the original HEAD pointer in a variable called ORIG_HEAD before doing dangerous operations, so it is simple to recover your branch at the state before the rebase/merge",
"mappedCommand": [
{ "command": "git","arguments": "reset --hard ORIG_HEAD"}
],
"options": []
},
{
"command": "undo merge",
"description": "You may have merged or rebased your current branch with a wrong branch, or you can't figure it out or finish the rebase/merge process. Git saves the original HEAD pointer in a variable called ORIG_HEAD before doing dangerous operations, so it is simple to recover your branch at the state before the rebase/merge",
"mappedCommand": [
{ "command": "git","arguments": "reset --hard ORIG_HEAD"}
],
"options": []
},
{
"command": "rebase without reflecting changes",
"description": "Unfortunately, you have to force push, if you want those changes to be reflected on the remote branch. This is because you have changed the history. The remote branch won't accept changes unless you force push. This is one of the main reasons many people use a merge workflow, instead of a rebasing workflow - large teams can get into trouble with developers force pushing. Use this with caution. A safer way to use rebase is not to reflect your changes on the remote branch at all, and instead to do the following",
"mappedCommand": [
{ "command": "git","arguments": "checkout {{{branch}}}"},
{ "command": "git","arguments": "rebase -i master"},
{ "command": "git","arguments": "checkout master"},
{ "command": "git","arguments": "merge --ff-only {{{branch}}}"}
],
"options": [{
"name": "branch",
"settings": {
"describe": "New remote branch name",
"required": true
}
}]
},
{
"command": "combine commits",
"description": "Let's suppose you are working in a branch that is/will become a pull-request against master. In the simplest case when all you want to do is to combine all commits into a single one and you don't care about commit timestamps, you can reset and recommit. Make sure the master branch is up to date and all your changes committed",
"mappedCommand": [
{ "command": "git","arguments": "reset --soft master"},
{ "command": "git","arguments": "commit -am \"{{{mymessage}}}\""}
],
"options": [{
"name": "mymessage",
"settings": {
"describe": "Commit message",
"required": true
}
}]
},
{
"command": "interactive rebase",
"description": "Combine commits with more control, and also to preserve timestamps, you need to do something called an interactive rebase",
"mappedCommand": [
{ "command": "git","arguments": "rebase -i master"}
],
"options": []
},
{
"command": "squash commits",
"description": "If you aren't working against another branch you'll have to rebase relative to your HEAD. If you want to squash the last 2 commits, for example, you'll have to rebase against HEAD~2. For the last 3, HEAD~3, etc",
"mappedCommand": [
{ "command": "git","arguments": "rebase -i HEAD~{{commits}}"}
],
"options": [{
"name": "commits",
"settings": {
"describe": "Number of commits to squash",
"required": true
}
}]
},
{
"command": "safe merging",
"description": "Performs the merge but pretends the merge failed and does not autocommit, giving the user a chance to inspect and further tweak the merge result before committing. no-ff maintains evidence that a feature branch once existed, keeping project history consistent",
"mappedCommand": [
{ "command": "git","arguments": "merge --no-ff --no-commit {{{branch}}}"}
],
"options": [{
"name": "branch",
"settings": {
"describe": "Branch name",
"required": true
}
}]
},
{
"command": "merge branch into single commit",
"description": "Merge a branch into a single commit",
"mappedCommand": [
{ "command": "git","arguments": "merge --squash {{{branch}}}"}
],
"options": [{
"name": "branch",
"settings": {
"describe": "Branch name",
"required": true
}
}]
},
{
"command": "combine unpushed commits",
"description": "Combine only unpushed commits. Interactive rebase that lists only the commits that you haven't already pushed, so it will be safe to reorder/fix/squash anything in the list",
"mappedCommand": [
{ "command": "git","arguments": "rebase -i @{u}"}
],
"options": []
},
{
"command": "abort merge",
"description": "Sometimes the merge can produce problems in certain files, in those cases we can use the option abort to abort the current conflict resolution process, and try to reconstruct the pre-merge state.",
"mappedCommand": [
{ "command": "git","arguments": "merge --abort"}
],
"options": []
},
{
"command": "check commits merged",
"description": "To check if all commits on a branch are merged into another branch, you should diff between the heads (or any commits) of those branche.",
"mappedCommand": [
{ "command": "git","arguments": "log --graph --left-right --cherry-pick --oneline HEAD...{{{branch}}}"}
],
"options": [{
"name": "commit",
"settings": {
"describe": "Branch name, commit etc",
"required": true
}
}]
},
{
"command": "list nonshared commits",
"description": "This will tell you if any commits are in one but not the other, and will give you a list of any nonshared between the branches.\n(Another option is to do this see \"check commits merged\").",
"mappedCommand": [
{ "command": "git","arguments": "log master ^{{{branch}}} --no-merges"}
],
"options": [{
"name": "commit",
"settings": {
"describe": "Branch name, commit etc",
"required": true
}
}]
},
{
"command": "visual diff editor",
"description": "If the merges are complicated, you can use a visual diff editor",
"mappedCommand": [
{ "command": "git","arguments": "mergetool -t opendiff"}
],
"options": []
},
{
"command": "stash file",
"description": "To stash only one file from your working directory",
"mappedCommand": [
{ "command": "git","arguments": "stash push {{{path}}}"}
],
"options": [{
"name": "path",
"settings": {
"describe": "path to the file",
"required": true
}
}]
},
{
"command": "stash with message",
"description": "stash with message",
"mappedCommand": [
{ "command": "git","arguments": "stash save \"{{{mymessage}}}\""}
],
"options": [{
"name": "mymessage",
"settings": {
"describe": "Comment stash",
"required": true
}
}]
},
{
"command": "delete submodule",
"description": "Remove a submodule",
"mappedCommand": [
{ "command": "git","arguments": "submodule deinit {{{mysubmodule}}}"},
{ "command": "git","arguments": "rm {{{mysubmodule}}}"},
{ "command": "git","arguments": "rm --cached {{{mysubmodule}}}"},
{ "command": "git","arguments": "-rf .git/modules/{{{mysubmodule}}}"}
],
"options": [{
"name": "mysubmodule",
"settings": {
"describe": "Submodule name",
"required": true
}
}]
},
{
"command": "restore file",
"description": "Restore deleted not commited file",
"mappedCommand": [
{ "command": "git","arguments": "checkout {{{filename}}}"}
],
"options": [{
"name": "filename",
"settings": {
"describe": "File name",
"required": true
}
}]
},
{
"command": "restore commited file",
"description": "Restore a deleted file from previous commit. Finds the commit when the file last existed then checkouts that file",
"mappedCommand": [
{ "command": "git","arguments": "checkout $(git rev-list -n 1 HEAD -- {{{filename}}})^ -- {{{filename}}}"}
],
"options": [{
"name": "filename",
"settings": {
"describe": "File name",
"required": true
}
}]
},
{
"command": "remove from git",
"description": "Remove a file from Git but keep the file",
"mappedCommand": [
{ "command": "git","arguments": "rm --cached {{{filename}}}"}
],
"options": [{
"name": "filename",
"settings": {
"describe": "File name",
"required": true
}
}]
},
{
"command": "add empty directory",
"description": "Add an empty directory to my repository",
"mappedCommand": [
{ "command": "mkdir","arguments": "{{{mydir}}}"},
{ "command": "touch","arguments": "{{{mydir}}}/.gitkeep"}
],
"options": [{
"name": "mydir",
"settings": {
"describe": "Directory path/name",
"required": true
}
}]
},
{
"command": "save credentials",
"description": "Cache a username and password for a repository",
"mappedCommand": [
{ "command": "git","arguments": "config --global credential.helper cache"}
],
"options": []
},
{
"command": "cache credentials",
"description": "Cache a username and password for a repository with timeout",
"mappedCommand": [
{ "command": "git","arguments": "config --global credential.helper 'cache --timeout={{{timeout}}}'"}
],
"options": [{
"name": "timeout",
"settings": {
"describe": "timeout in seconds",
"required": true
}
}]
}
]}