Skip to content

Commit dc3d7b9

Browse files
committed
docs: pull changes of specific files
1 parent 86226a5 commit dc3d7b9

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

toc-source.json

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,10 @@
494494
],
495495
"tags": ["patch", "format-patch", "committed"],
496496
"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+
}
498501
],
499502
"author": "mike-rambil",
500503
"last_updated": "2024-06-10"
@@ -534,7 +537,10 @@
534537
],
535538
"tags": ["diff", "uncommitted", "snapshot"],
536539
"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+
}
538544
],
539545
"author": "mike-rambil",
540546
"last_updated": "2024-06-10"
@@ -565,5 +571,41 @@
565571
"last_updated": "2024-06-10"
566572
}
567573
]
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+
]
568610
}
569611
]

0 commit comments

Comments
 (0)