|
494 | 494 | ], |
495 | 495 | "tags": ["patch", "format-patch", "committed"], |
496 | 496 | "links": [ |
497 | | - {"label": "Official Docs", "url": "https://git-scm.com/docs/git-format-patch"} |
| 497 | + { |
| 498 | + "label": "Official Docs", |
| 499 | + "url": "https://git-scm.com/docs/git-format-patch" |
| 500 | + } |
498 | 501 | ], |
499 | 502 | "author": "mike-rambil", |
500 | 503 | "last_updated": "2024-06-10" |
|
534 | 537 | ], |
535 | 538 | "tags": ["diff", "uncommitted", "snapshot"], |
536 | 539 | "links": [ |
537 | | - {"label": "Official Docs", "url": "https://git-scm.com/docs/git-diff"} |
| 540 | + { |
| 541 | + "label": "Official Docs", |
| 542 | + "url": "https://git-scm.com/docs/git-diff" |
| 543 | + } |
538 | 544 | ], |
539 | 545 | "author": "mike-rambil", |
540 | 546 | "last_updated": "2024-06-10" |
|
565 | 571 | "last_updated": "2024-06-10" |
566 | 572 | } |
567 | 573 | ] |
| 574 | + }, |
| 575 | + { |
| 576 | + "Name": "Pull Changes of Specific Files from a Commit", |
| 577 | + "category": "Selective File Restore", |
| 578 | + "short_description": "Restore or pull changes for specific files from a past commit without reverting the entire commit.", |
| 579 | + "long_description": "How to use git to pull or restore changes for only certain files from a specific commit, without affecting the rest of your working directory or reverting the whole commit. Useful for cherry-picking file-level changes.", |
| 580 | + "command": "git checkout <commit-hash> -- <file1> <file2>", |
| 581 | + "examples": [ |
| 582 | + { |
| 583 | + "code": "git checkout e8ab7f64fdfcc7bdaaed8d96c0ac26dce035663f -- path/to/file1.txt path/to/file2.txt", |
| 584 | + "description": "Restore file1.txt and file2.txt from the specified commit." |
| 585 | + }, |
| 586 | + { |
| 587 | + "code": "git add path/to/file1.txt path/to/file2.txt\ngit commit -m \"Pulled changes for file1.txt and file2.txt from commit e8ab7f64\"\ngit push origin revert/productionOrder", |
| 588 | + "description": "Stage, commit, and push the restored files to a new branch." |
| 589 | + } |
| 590 | + ], |
| 591 | + "steps": [ |
| 592 | + "Checkout the specific files from the desired commit using 'git checkout <commit-hash> -- <file1> <file2>'.", |
| 593 | + "Stage the changes with 'git add <file1> <file2>'.", |
| 594 | + "Commit the changes with a descriptive message.", |
| 595 | + "Push your branch and create a pull request if needed." |
| 596 | + ], |
| 597 | + "warnings": [ |
| 598 | + "This will overwrite the current working directory versions of the specified files.", |
| 599 | + "Make sure to commit or stash any local changes to those files before running the command." |
| 600 | + ], |
| 601 | + "tags": ["checkout", "restore", "file", "commit", "cherry-pick"], |
| 602 | + "author": "mike-rambil", |
| 603 | + "last_updated": "2024-06-10", |
| 604 | + "links": [ |
| 605 | + { |
| 606 | + "label": "Git Docs: git checkout", |
| 607 | + "url": "https://git-scm.com/docs/git-checkout" |
| 608 | + } |
| 609 | + ] |
568 | 610 | } |
569 | 611 | ] |
0 commit comments