blob: 421e2955f1b7cbcbdbd6dff2ac1c13255293dc37 (
about) (
plain) (
blame)
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
|
#
msgid ""
msgstr ""
msgid ""
"I commonly use tools like `git log` together with `git show` when inspecting"
" past changes in a repository:"
msgstr ""
msgid ""
"But I also wanted to not only be able to look at the diff of a specific "
"commit, but to browse the whole repository at that specific commit."
msgstr ""
msgid ""
"I used to accomplish it the \"brute force\" way: clone the whole repository "
"in another folder and checkout the commit there:"
msgstr ""
msgid ""
"But git itself allows we to specific the directory of the checkout by using "
"the `--work-tree` global git flag. This is what `man git` says about it:"
msgstr ""
msgid ""
"So it allows us to set the desired path of the working tree. So if we want "
"to copy the contents of the current working tree into `copy/`:"
msgstr ""
msgid ""
"After that `copy/` will contain a replica of the code in HEAD. But to "
"checkout a specific, we need some extra parameters:"
msgstr ""
msgid ""
"There's an extra `-- .` at the end, which initially looks like we're sending"
" Morse signals to git, but we're actually saying to `git-checkout` which sub"
" directory of `<my-commit>` we want to look at. Which means we can do "
"something like:"
msgstr ""
msgid ""
"And with that `<dir>` will only contain what was inside `src/` at "
"`<commit>`."
msgstr ""
msgid ""
"After any of those checkouts, you have to `git reset .` to reset your "
"current staging area back to what it was before the checkout."
msgstr ""
msgid "References:"
msgstr ""
msgid ""
"[GIT: Checkout to a specific folder](https://stackoverflow.com/a/16493707) "
"(StackOverflow)"
msgstr ""
msgid ""
"git log\n"
"# search for a the commit I'm looking for\n"
"git show <my-commit>\n"
"# see the diff for the commit\n"
msgstr ""
msgid ""
"git clone <original-repo> /tmp/tmp-repo-clone\n"
"cd /tmp-repo-clone\n"
"git checkout <my-commit>\n"
msgstr ""
msgid ""
"--work-tree=<path>\n"
" Set the path to the working tree. It can be an absolute path or a path relative to the current working\n"
" directory. This can also be controlled by setting the GIT_WORK_TREE environment variable and the\n"
" core.worktree configuration variable (see core.worktree in git-config(1) for a more detailed\n"
" discussion).\n"
msgstr ""
msgid ""
"mkdir copy\n"
"git --work-tree=copy/ checkout .\n"
msgstr ""
msgid "git --work-tree=<dir> checkout <my-commit> -- .\n"
msgstr ""
msgid "git --work-tree=<dir> checkout <my-commit> -- src/\n"
msgstr ""
msgid "title: Browse a git repository at a specific commit"
msgstr ""
msgid "date: 2020-08-14"
msgstr ""
msgid "layout: post"
msgstr ""
msgid "lang: en"
msgstr ""
msgid "ref: browse-a-git-repository-at-a-specific-commit"
msgstr ""
msgid "eu_categories: git"
msgstr ""
#~ msgid ""
#~ "title: Browse a git repository at a specific commit\n"
#~ "date: 2020-08-14\n"
#~ "layout: post\n"
#~ "lang: en\n"
#~ "ref: browse-a-git-repository-at-a-specific-commit"
#~ msgstr ""
|