/
index.html
179 lines (179 loc) · 14.4 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Rename GitHub Default Branches</title>
<link href="./rename.css" rel="stylesheet">
</head>
<body>
<div class="wrapper">
<h1>Rename GitHub Default Branches</h1>
<a href="https://github.com/eyqs/rename-github-default-branches">
<img id="github" src="https://camo.githubusercontent.com/a6677b08c955af8400f44c6298f40e7d19cc5b2d/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677261795f3664366436642e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png">
</a>
<p>This tool lets you rename your GitHub default branches to whatever you want.</p>
<p>Create a <a href="https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line">GitHub personal access token</a> with the <strong>repo</strong> scope, fill out the fields, but don't check the box unless you <strong>know</strong> those branches are safe to delete!</p>
<p>When you submit the form, this <a href="./rename.js">short JavaScript snippet</a> is run, entirely on your local machine, making no network requests to any servers besides through the GitHub API. If you don't trust sketchy webapps despite the countless perfectly legitimate testimonials, please copy the JavaScript code and run it yourself.</p>
<form id="form">
<label>
<p>Name of old default branch:</p>
<input name="old_branch" type="text" required="required" placeholder="master">
</label>
<label>
<p>Name of new default branch:</p>
<input name="new_branch" type="text" required="required" placeholder="main">
</label>
<label>
<p>GitHub personal access token:</p>
<input name="token" type="text" required="required" placeholder="fbe2e2c7883d61ad193883098c7e93449c260ba9">
</label>
<label>
<p>Delete old default branches after switching to new default branches?</p>
<div>
<input name="del" type="checkbox">
<input type="submit" value="Start!">
</div>
</label>
</form>
<h2 class="space">Frequently Asked Questions</h2>
<ul>
<li>
<p class="question">What's a default branch?</p>
<p class="answer">It's the <a href="https://help.github.com/en/github/administering-a-repository/setting-the-default-branch">base branch in a GitHub repository</a>, which by default is <code>master</code>. </p>
</li>
<li>
<p class="question">Why should I use this tool?</p>
<p class="answer">Freedom of speech! Defy conventions! Express yourself in one word!</p>
</li>
<li>
<p class="question">Who, other than suspicious testimonials, would trust this site?</p>
<p class="answer">Nobody. So you should really read <a href="./rename.js">the source code</a> and run it yourself.</p>
</li>
<li>
<p class="question">Will I encounter issues if branches with the same name already exist, or if there are many external hyperlinks to the <code>master</code> branch, or if many people use my repo as a submodule, or if I have many forks I don't want to touch, or if I have over 1239 repositories, or if I'm using multiple remotes, or if I'm using Netscape Navigator 3.02?</p>
<p class="answer">Yes, yes, yes, yes, yes, yes, and yes. In any case, <strong>don't use this tool.</strong> Nevertheless, feel free to modify it to suit your needs!</p>
</li>
<li>
<p class="question">Would any changes be irreversible?</p>
<p class="answer">Not unless you check the box to delete your old default branches. Usually, you can just run the script again in reverse to undo your changes. Otherwise, if you're not a casual user (see above), this tool isn't for you.</p>
</li>
<li>
<p class="question">Whose repositories does this affect?</p>
<p class="answer">This script only affects repos under your username, unfortunately <strong>including all forks</strong>. It does not affect any repos owned by organizations, even if you are an owner of such a repo, because presumably you should probably consult your collaborators first before breaking everything.</p>
</li>
<li>
<p class="question">Which scopes should I select when creating my token?</p>
<p class="answer">You should select <strong>repo</strong> if you want to change both public and private repos, or just <strong>public_repo</strong> if you don't trust that I wouldn't "accidentally" delete all your private repos. Remember to revoke your token afterwards!</p>
</li>
<li>
<p class="question">Where's the progress indicator?</p>
<p class="answer">You can <a href="https://webmasters.stackexchange.com/a/77337">open up the JavaScript console</a> to see some output. A list of results for all repositories will show up at the very end, so be patient.</p>
</li>
<li>
<p class="question">Whatever shall I do, in order to switch to my new branch on my local repositories after running this script?</p>
<p class="answer">If you're scared of Git, you can do the usual: delete and clone again.</p>
<p>If your local branch is behind or even with your remote branch, try:</p>
<pre>
git pull
git checkout <new_branch>
git branch -d <old_branch>
git remote update -p
</pre>
<p>If your local branch is ahead of your remote branch, try:</p>
<pre>
git checkout -b <new_branch>
git branch -d <old_branch>
git push <remote> -u <new_branch>
git remote update -p
</pre>
<p>Here's an example of the bash loop that I used:</p>
<pre>
for d in ./*/; do (
cd "$d" &&
git pull &&
git checkout salad &&
git branch -d master &&
git remote update -p
) done
</pre>
</li>
<li>
<p class="question">Whom should I ask for help in configuring <code>git init</code> to initialize new repositories with a different default branch?</p>
<p class="answer">See <a href="https://stackoverflow.com/a/50880622">this StackOverflow answer by nicoo</a> for details.</p>
</li>
<li>
<p class="question">When will you write a script to rename GitLab default branches?</p>
<p class="answer">Tomorrow, if this gets over 10 upvotes on <a href="https://news.ycombinator.com/item?id=23563950">Hacker News</a> or <a href="https://old.reddit.com/r/github/comments/hbit51/">Reddit</a>. Otherwise never, because nobody would ever use it, not even myself. [<strong>Update:</strong> I got four upvotes on both Hacker News and Reddit, so <strong>never</strong>. Reddit and the eight people who downvoted this must hate free speech!]</p>
</li>
<li>
<p class="question">Was this script thoroughly checked for bugs?</p>
<p class="answer">No. I express no representation or warranties of any kind whatsoever, including without limitation the implied warranties of merchantability and fitness for a particular purpose, all of which I hereby disclaim to the fullest extent permitted by law.</p>
</li>
<li>
<p class="question">Whoever could have "accidentally" deleted all of my repos?</p>
<p class="answer">It wasn't me! Again, please read <a href="./rename.js">the source code</a> to double-check.</p>
</li>
<li>
<p class="question">Were any of these "frequently" asked questions ever asked?</p>
<p class="answer">No.</p>
</li>
</ul>
<h2 class="space">Testimonials</h2>
<p>@<a href="https://github.com/eyqs">eyqs</a>: <q>Amazing tool. If this didn't already exist, I would have written it myself!</q></p>
<p>@<a href="https://github.com/oirectine">oirectine</a>: <q>i haven’t used it but i’m sure it probably works</q></p>
<p>@<a href="https://github.com/danield128">danield128</a>: <q>Rename is so easy to use! We plan to replace git with rename as our exclusive version control system. Thanks @<a href="https://github.com/eyqs">eyqs</a>!</q></p>
<p>@<a href="https://github.com/emsal1863">emsal1863</a>: <q>I was paid $0.10 to give my 2 cents here. This script sucks!!!</q></p>
<p>@<a href="https://github.com/Schemetrical">Schemetrical</a>: <q>Never used tool</q></p>
<p>@<a href="https://github.com/mo-morgan">mo-morgan</a>: <q>this tool will definitely advance humanity 10/10</q></p>
<p>@<a href="https://github.com/fb39ca4">fb39ca4</a>: <q>I can now sleep at night knowing racism has ended.</q></p>
<p>@<a href="https://github.com/jzaralim">jzaralim</a>: <q>none of the people in the testimonials even used the tool...</q></p>
<p>@<a href="https://github.com/rhymu8354">rhymu8354</a>: <q>The tool you wrote is very neat! I thought about making a tool that just does the "patch" part (changing the default branch) but in the end I opted to just change them all manually since it didn't take long. However, I'm sure your tool could be handy for others, especially if there are a lot of repos to go through.</q></p>
<p>@<a href="https://github.com/priyanshmalik">priyanshmalik</a>: <q>this sounds like a lot of effort when I only have one repository</q></p>
<p>@<a href="https://github.com/ben324">ben324</a>: <q>YOOOOooOOOOoOoOo i don't even have any repositories!!!!</q></p>
<p>@<a href="https://github.com/gwenli">gwenli</a>: <q>what is this</q></p>
<p>@<a href="https://github.com/rachitkumar">rachitkumar</a>: <q>This tool is useless</q></p>
<p>@<a href="https://github.com/lynnzhang7">lynnzhang7</a>: <q>I don't remember how to git and I also got locked out of my account last year but if I could use it im sure this would be life changing</q></p>
<p>@<a href="https://github.com/shadjamaldeen">nishadjamaldeen</a>: <q>I used to spend a lot of my time trying to rename my github branches. Now, its done at the click of a button!</q></p>
<p>@<a href="https://github.com/zcliang97">zcliang97</a>: <q>It’s apps like these that make me think the future is here. <a href="https://twitter.com/search?q=%23GoodThingsHappenIn2020Too">#GoodThingsHappenIn2020Too</a></q></p>
<p>@<a href="https://github.com/s-zheng">s-zheng</a>: <q>this cured my cancer</q></p>
<p>@<a href="https://github.com/rebeccayelin">rebeccayelin</a>: <q>...</q></p>
<p>@<a href="https://github.com/estherlin">estherlin</a>: <q>this is so much better than plain old <code>git branch -m master salad</code>.</q></p>
<p>@<a href="https://github.com/gzgreg">gzgreg</a>: <q>pretty sure this got one of my coworkers fired yesterday when all the links to <code>tree/master</code> broke, nice job</q></p>
<p>@<a href="https://github.com/andersfylling">andersfylling</a>: <q>So I can rename it to <code>master</code> after GitHub takes this race play too far?</q></p>
<p>@<a href="https://github.com/divyabudihal">divyabudihal</a>: <q>this is so important in 2020! We must work to completely abolish terms like <code>master</code> from the tech world!</q></p>
<p>@<a href="https://github.com/maggiechen">maggiechen</a>: <q>ah I see, doing away with the master slave terminology</q></p>
<p>@<a href="https://github.com/ShuHaoLi">ShuHaoLi</a>: <q>masterful.</q></p>
<p>@<a href="https://github.com/mkduan">mkduan</a>: <q>I always felt like <code>master</code> was a little bit too oppressive for me, now I feel much safer coding! 10/5 would recommend it to anyone!</q></p>
<p>@<a href="https://github.com/jnancy">jnancy</a>: <q>🥵😤💦</q></p>
<p>@<a href="https://github.com/Cesium-Ice">Cesium-Ice</a>: <q>The author has excellent taste in anime.</q></p>
<p>@<a href="https://github.com/eishan05">eishan05</a>: <q>I am surprised this tool doesn’t need a credit card number and the three digits on the back to work, considering I discovered it on a kissanime ad banner</q></p>
<p>@<a href="https://github.com/Andrew-Ting">Andrew-Ting</a>: <q>すごい!このツールは面白くて、かっこいいですよ!やれやれだぜ。Grabe talaga yung tool na ito. Napakagaling, di mo na kailangan magsulat ng git commands sa terminal. Astig!</q></p>
<p>@<a href="https://github.com/izyb">izyb</a>: <q>this gave me cancer</q></p>
<p>@<a href="https://github.com/davidberard98">davidberard98</a>: <q>yikes</q></p>
<p>@<a href="https://github.com/Chenart">Chenart</a>: <q>I'd love to invest in your startup but I just don't see a clear monetization strategy.</q></p>
<p>@<a href="https://github.com/Bruno-DaSilva">Bruno-DaSilva</a>: <q>Is this web scale? MongoDB is web scale. Can this use MongoDB?</q></p>
<p>@<a href="https://github.com/ehnryx">ehnryx</a>: <q>scary. can this defeat science advising?</q></p>
<p>@<a href="https://github.com/blin4444">blin4444</a>: <q>oh no, what if it steals my API keys</q></p>
<p>@<a href="https://github.com/EbTech">EbTech</a>: <q>The source code ain't Rust, can't trust it. I hardly even trust my own code.</q></p>
<p>@<a href="https://github.com/silastsui">silastsui</a>: <q>this tool will turn u into a 10x developer</q></p>
<p>@<a href="https://github.com/esemeniuc">esemeniuc</a>: <q>This tool renamed my life. I am now X Æ A-12 Musk</q></p>
<p>@<a href="https://github.com/ezaanm">ezaanm</a>: <q>pog</q></p>
<p>@<a href="https://github.com/bogwarts">bogwarts</a>: <q>So convenient and such a good idea! Thanks for building!</q></p>
<p>@<a href="https://github.com/luccasiau">luccasiau</a>: <q>Eugene told me this tool is great and I think he's right</q></p>
<p>@<a href="https://github.com/d-e-lu">d-e-lu</a>: <q>According to Eugene I can use this to make myself look cool. Thanks Eugene!!!</q></p>
<p>@<a href="https://github.com/felixhe97">felixhe97</a>: <q>Writing testimonial because I just want to feel included.</q></p>
<p>@<a href="https://github.com/Visible1">Visible1</a>: <q>i dont social distance much</q></p>
<p>@<a href="https://github.com/SoleSun">SoleSun</a>: <q>LOOL sorey I missed it, I defijitely didnt know what was happening</q></p>
<p>@<a href="https://github.com/wollip">wollip</a>: <q>seems cool, probably won’t use it. I like my repos the way they are. This is going to break my repos that have multiple remotes.</q></p>
<p>@<a href="https://github.com/Thanh-To">Thanh-To</a>: <q>I was probably the only person who actually used it? Works as intended. I’m deleting the token just in case.</q></p>
<p>...and if you'd like to create/update/destroy your own testimonial, <a href="https://github.com/eyqs/rename-github-default-branches/issues">raise an issue</a>!</p>
</div>
<footer role="contentinfo">
<small>
<p>Copyright and related rights waived via <a href="http://creativecommons.org/publicdomain/zero/1.0/">CC0</a>.</p>
</small>
</footer>
<script src="./rename.js"></script>
</body>
</html>