@@ -13,6 +13,7 @@ This index is generated by [readme_generate_index.sh](https://github.com/HariSek
13
13
- [ Git HTTP Authentication] ( #git-https-authentication )
14
14
- [ CLIs] ( #clis )
15
15
- [ GitHub Badges] ( #github-badges )
16
+ - [ The Evils of Rebasing] ( #the-evils-of-rebasing )
16
17
- [ Git LFS] ( #git-lfs )
17
18
- [ Why You Need Git LFS for Large Files] ( #why-you-need-git-lfs-for-large-files )
18
19
- [ Git LFS on other git hosting providers] ( #git-lfs-on-other-hosting-providers )
@@ -58,58 +59,6 @@ https://datasift.github.io/gitflow/IntroducingGitFlow.html
58
59
59
60
https://nvie.com/posts/a-successful-git-branching-model/
60
61
61
- ## The Evils of Rebasing
62
-
63
- Some people like rebasing to make their ` git log --graph ` look like a straight line,
64
- albeit with out of order timestamps 🙄.
65
-
66
- This violates the classic version control principle of not altering history.
67
-
68
- Git lets you get away with this because Git is ultra powerful, but...
69
-
70
- #### Cautionary Tale from Experience
71
-
72
- I spent half an hour helping a colleague in Denmark hack and edit through files in merge conflict after merge conflict
73
- on two dozen commits due to him doing a rebase.
74
-
75
- These were commits that would have been auto-resolved by a default merge commit (which is why it's the default) as the
76
- end states were the same on both branches and only the intermediate commits were different.
77
-
78
- Needless stress and potential for introducing code editing errors on each rebase commit step
79
- multiplied by two dozen commits multiplied by the number of files changed with conflicts in those commits.
80
-
81
- Never again.
82
-
83
- #### Force Push Overwrites Can Lose Code Permanently
84
-
85
- If you've already pushed your branch upstream, you then have to force push to overwrite your own upstream commit history
86
- after a rebase. Yuck.
87
-
88
- If you still insist on doing rebasing for the love of goodness please use ` --force-with-lease ` instead of ` --force ` .
89
-
90
- This switch checks that the remote branch hasn't been changed since your last fetch since you're overwriting it,
91
- which would otherwise lose those commits.
92
-
93
- But unfortunately even this is trivially defeated, read the [ git push] ( https://git-scm.com/docs/git-push ) man page on
94
- this for more details.
95
-
96
- Do you get why you shouldn't rebase to try to have a single straight ` git log --graph ` line yet?
97
-
98
- Yes you can accidentally delete code even after it's been pushed and lose it forever in Git. This is not Subversion.
99
-
100
- With great power comes great responsibility...
101
-
102
- ### Squash Commits
103
-
104
- Squash commit merges have a similar issue
105
- to rebasing in that they lose intermediate commits and keep only the very last version of the branch code,
106
- losing the process and any code/comments/commit messages that might have been useful to keep as references in the history.
107
-
108
- Future engineers doing ` git log ` will not be able to see the process of the evolution of your code,
109
- only the very final version, somewhat defeating the purpose of version control history!
110
-
111
- If I had to pick my battles and let my engineers do one or the other,
112
- I'd ban rebasing though after my Denmark experience.
113
62
114
63
## Advanced Git Config
115
64
@@ -184,6 +133,70 @@ pip install --user bitbucket-cli
184
133
## GitHub Badges
185
134
186
135
https://github.com/commonality/architecture-decision-records/wiki/GitHub-repository-status-badges
136
+ ## The Evils of Rebasing
137
+
138
+ Some people like rebasing to make their ` git log --graph ` look like a straight line,
139
+ albeit with out of order timestamps 🙄.
140
+
141
+ This violates the classic version control principle of not altering history.
142
+
143
+ Git lets you get away with this because Git is ultra powerful, but...
144
+
145
+ #### Cautionary Tale from Experience
146
+
147
+ I spent half an hour helping a colleague in Denmark hack and edit through files in merge conflict after merge conflict,
148
+ on two dozen commits due to him doing a rebase.
149
+
150
+ You thought one merge conflict was bad? Try two dozen in a row...
151
+
152
+ Welcome to "Rebase Hell".
153
+
154
+ These were commits that would have been auto-resolved by a default merge commit (which is why it's the default) as the
155
+ end states were the same on both branches and only the intermediate commits were different.
156
+
157
+ Yes I know two people shouldn't have been producing similar fixes on two branches but something people are in a rush and
158
+ these things happen. Besides, this is supposed to be distributed concurrent version control.
159
+
160
+ If you think that's bad, I've worked for another company which has both ` develop ` and ` master ` branches being used
161
+ in production but which have diverged by 10,000 commits such that they cannot merge or reconcile them and must
162
+ manually copy code changes and commit to both branches.
163
+
164
+ Anyway, this "Rebase Hell" situation resulted in needless hassle and potential for introducing code editing errors on
165
+ each rebase commit step
166
+ multiplied by two dozen commits multiplied by the number of files changed with conflicts in those commits.
167
+
168
+ Never again.
169
+
170
+ #### Force Push Overwrites Can Lose Code Permanently
171
+
172
+ If you've already pushed your branch upstream, you then have to force push to overwrite your own upstream commit history
173
+ after a rebase. Yuck.
174
+
175
+ If you still insist on doing rebasing for the love of goodness please use ` --force-with-lease ` instead of ` --force ` .
176
+
177
+ This switch checks that the remote branch hasn't been changed since your last fetch since you're overwriting it,
178
+ which would otherwise lose those commits.
179
+
180
+ But unfortunately even this is trivially defeated, read the [ git push] ( https://git-scm.com/docs/git-push ) man page on
181
+ this for more details.
182
+
183
+ Do you get why you shouldn't rebase to try to have a single straight ` git log --graph ` line yet?
184
+
185
+ Yes you can accidentally delete code even after it's been pushed and lose it forever in Git. This is not Subversion.
186
+
187
+ With great power comes great responsibility...
188
+
189
+ ### Squash Commits
190
+
191
+ Squash commit merges have a similar issue
192
+ to rebasing in that they lose intermediate commits and keep only the very last version of the branch code,
193
+ losing the process and any code/comments/commit messages that might have been useful to keep as references in the history.
194
+
195
+ Future engineers doing ` git log ` will not be able to see the process of the evolution of your code,
196
+ only the very final version, somewhat defeating the purpose of version control history!
197
+
198
+ If I had to pick my battles and let my engineers do one or the other,
199
+ I'd ban rebasing though after my Denmark experience.
187
200
188
201
## Git LFS
189
202
0 commit comments