~hristoast/hristoast

ref: f79fb3ab388c681764cb4b344a4c224e9a6ffc34 hristoast/site/always-learning-new-git-tricks.html -rw-r--r-- 1.4 KiB
f79fb3abHristos N. Triantafillou Inject the js at the end of body, not somewhere in the middle 1 year, 10 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<h1 id="title">Always learning: new git tricks</h1>

<div id="dates">
  <span>Posted: <time id="post-date">2017-09-14</time></span>
</div>

<p>
  Imagine the following scenario:  you keep the dotfiles for several machines under one git repo with some submodules, including one machine which clones a submodule from a GitHub repo that I own (so it's cloned over SSH, not HTTPS.)  No problem when I do a recursive clone when using a key that's connected to my GitHub account - but when I'm on my gaming rig, or any other machine that is not connected, that clone URL fails as does the overall recursive clone operation.  This can be "cleaned up" by hand but is a pain.
</p>

<p>
  Enter <a href="https://git-scm.com/docs/git-config#git-config-urlltbasegtinsteadOf"><code>url.&lt;base&gt;.pushInsteadOf</code></a>!  With a quick one-liner or entry in your relevant git config, the above issue is solved by translating the <code>git@github.com:</code> URL into <code>https://github.com/</code>, seamlessly.  In my case, a global change did the trick for the machines that needed it:
</p>

<pre><code>git config --global url."https://github.com/".insteadOf git@github.com:</code></pre>

<p>
  Which added the following to my <code>.gitconfig</code>:
</p>

<pre><code>[url "https://github.com/"]
	insteadOf = git@github.com:</code></pre>

And now that machine seamlessly translates that URL to one that's usable (when cloning.)  Pretty rad!