<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="https://esolitos.com"  xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>esolitos.com - github</title>
 <link>https://esolitos.com/tags/github</link>
 <description></description>
 <language>en</language>
<item>
 <title>(Automatically) Move my git repositories from Bitbucket to Github</title>
 <link>https://esolitos.com/items/2019/07/automatically-move-my-git-repositories-bitbucket-github</link>
 <description>&lt;div class=&quot;field field-name-field-byline field-type-entityreference field-label-hidden&quot;&gt;
      &lt;div  class=&quot;ds-1col node node-profile view-mode-byline clearfix&quot;&gt;

  
  &lt;div class=&quot;field field-name-field-photo field-type-image field-label-hidden&quot;&gt;
    
      &lt;a href=&quot;/profile/esolitos-marlon&quot;&gt;&lt;img src=&quot;https://esolitos.com/sites/default/files/styles/byline/public/field/image/screen_shot_2015-05-08_at_20.22.00.png?itok=cCjKAYpk&quot; width=&quot;50&quot; height=&quot;50&quot; /&gt;&lt;/a&gt;    
&lt;/div&gt;
&lt;div class=&quot;field field-name-title field-type-ds field-label-hidden&quot;&gt;
    
      &lt;strong class=&quot;profile-name&quot;&gt;&lt;a href=&quot;/profile/esolitos-marlon&quot;&gt;Esolitos Marlon&lt;/a&gt;&lt;/strong&gt;    
&lt;/div&gt;
&lt;div class=&quot;field field-name-field-profession field-type-text field-label-hidden&quot;&gt;
    
      Web Developer and Duck Slayer    
&lt;/div&gt;
&lt;/div&gt;

  &lt;/div&gt;
&lt;div class=&quot;field field-name-post-date field-type-ds field-label-hidden&quot;&gt;
    
      Sunday, 14 July, 2019 - 22:43    
&lt;/div&gt;
&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;
    
      &lt;p&gt;&lt;small&gt;&lt;em&gt;If you&#039;re not interested into the backstory, but only want to know about the script, &lt;a href=&quot;#run-the-script&quot;&gt;click here&lt;/a&gt;&lt;/em&gt;&lt;/small&gt;&lt;/p&gt;
&lt;h2&gt;Why, you might wonder?&lt;/h2&gt;
&lt;p&gt;Until today I was hosting my public repositories on Github and my private repositories on BitBucket. You might easily guess the reason: until few months ago to host private repositories on Github a subscription was required, and when I started having this requirement i could &quot;not afford&quot; the github pricing.&lt;br /&gt;
Now times have changed and not only I can afford Github Pro, but also this platform started offering free private repositories &lt;em&gt;(thanks Microsoft)&lt;/em&gt;, so I decided that I was going to simply merge all my codebases in one place, for pracicality.&lt;/p&gt;
&lt;h3&gt;The choice!&lt;/h3&gt;
&lt;p&gt;Well, I had to choose if move everything on Bitbucket or Github, this choice was actually rather easy.&lt;br /&gt;
While BB &lt;a href=&quot;https://bitbucket.org/product/comparison/bitbucket-vs-github&quot;&gt;seems to be actually more feature rich&lt;/a&gt; then GH for my usage most features are not very useful and to be honest i find BB user interface horribly slow and not very pleasant, even tho I must admit they&#039;ve done quite some progress in the past years.&lt;/p&gt;
&lt;p&gt;So bottom line, without to much thinking Github was the choice.&lt;/p&gt;
&lt;h2&gt;How?&lt;/h2&gt;
&lt;p&gt;Well, given that I had around 80 private repositories to move, manual work was definitely not an option, therefore I went for my scripting language of choice: &lt;code&gt;python&lt;/code&gt;!&lt;/p&gt;
&lt;p&gt;The script itself is rather easy, it&#039;s broken down in a few simple steps:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Get all repos in BitBucket &lt;em&gt;(and loop thought them)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Create a new repo on GitHub with the same slug name &lt;em&gt;(ensures there isn&#039;t already one with the same name)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Does a bare clone of the BB repo and mirros it to GH&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Nothing crazy, just a simple 150 lines script, you can view the source of it embedded at the bottom of this article or &lt;a href=&quot;https://gist.github.com/esolitos/da1083f57ac7e3f38cc8225cd00b11e6&quot;&gt;here on a gist on GH.&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Comments?&lt;/h2&gt;
&lt;p&gt;If you have any comments please reach me via Twitter. &lt;/p&gt;
&lt;blockquote class=&quot;twitter-tweet&quot; data-lang=&quot;en&quot;&gt;&lt;p dir=&quot;ltr&quot; lang=&quot;en&quot; xml:lang=&quot;en&quot;&gt;(Automagically) Moving my repositories from &lt;a href=&quot;https://twitter.com/Bitbucket?ref_src=twsrc%5Etfw&quot;&gt;@Bitbucket&lt;/a&gt; to &lt;a href=&quot;https://twitter.com/github?ref_src=twsrc%5Etfw&quot;&gt;@GitHub&lt;/a&gt;.&lt;a href=&quot;https://t.co/9n0Fe6AksU&quot;&gt;https://t.co/9n0Fe6AksU&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;— Marlon (@Esolitos) &lt;a href=&quot;https://twitter.com/Esolitos/status/1150517494928596992?ref_src=twsrc%5Etfw&quot;&gt;July 14, 2019&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;script async=&quot;&quot; src=&quot;https://platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;&lt;h2&gt;&lt;a name=&quot;run-the-script&quot; id=&quot;run-the-script&quot;&gt;&lt;/a&gt;How to run the script!&lt;/h2&gt;
&lt;p&gt;The only requirement is to have &lt;code&gt;pipenv&lt;/code&gt;, installing it outside the scope of this article, but if are on macOS it could be simply running &lt;code&gt;$ brew install pipenv&lt;/code&gt;, for more info consult &lt;a href=&quot;https://docs.pipenv.org/en/latest/&quot;&gt;the official documentation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To run the script you should update the following variables, which can be found on top of the script:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;APP_KEYS&lt;/code&gt;: A map containing the keys to authenticate on BB and GH.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;BB_USER&lt;/code&gt;: Your username on BitBucket&lt;/li&gt;
&lt;li&gt;&lt;code&gt;GH_USER&lt;/code&gt;: Your username on GitHub&lt;/li&gt;
&lt;li&gt;&lt;code&gt;BB_EMAIL&lt;/code&gt;: The email which will be used to identify your client against the BitBucket API.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Once you have done this the job is simple, initialise the pipenv via &lt;code&gt;$ pipenv install&lt;/code&gt; and once all dependencies have been installed just run the script with &lt;code&gt;$ pipenv shell&lt;/code&gt; followed by &lt;code&gt;$ python ./repository-migrate.py&lt;/code&gt;&lt;br /&gt;
If all went fine in a few minutes &lt;em&gt;(speed depends on your connection and amount of repositores)&lt;/em&gt; all your repositores on BB will be mirrored on GH while preserving the &quot;private&quot; status!&lt;/p&gt;
&lt;h2&gt;The script&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;Don&#039;t forget that you&#039;ll also need the &lt;a href=&quot;https://gist.github.com/esolitos/da1083f57ac7e3f38cc8225cd00b11e6#file-pipfile&quot;&gt;Pipfile&lt;/a&gt;, full gist source &lt;a href=&quot;https://gist.github.com/esolitos/da1083f57ac7e3f38cc8225cd00b11e6&quot;&gt;here&lt;/a&gt;!&lt;/em&gt;&lt;/p&gt;
&lt;script src=&quot;https://gist.github.com/esolitos/da1083f57ac7e3f38cc8225cd00b11e6.js?file=repository-migrate.py&quot;&gt;&lt;/script&gt;    
&lt;/div&gt;
&lt;div class=&quot;field field-name-field-tags field-type-taxonomy-term-reference field-label-inline clearfix&quot;&gt;
  &lt;div class=&quot;field-label&quot;&gt;Tags:&amp;nbsp;&lt;/div&gt;

  &lt;ul class=&quot;inline-list&quot;&gt;
          &lt;li&gt;&lt;a href=&quot;/tags/git&quot;&gt;git&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;/tags/bitbucket&quot;&gt;bitbucket&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;/tags/github&quot;&gt;github&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;/tags/python&quot;&gt;python&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
&lt;/div&gt;
&lt;div class=&quot;field field-name-field-subtitle field-type-text field-label-above&quot;&gt;
      &lt;div class=&quot;field-label&quot;&gt;Subtitle:&amp;nbsp;&lt;/div&gt;
    
      &lt;div class=&quot;field-content single-item&quot;&gt;Please ignore the single point of failure I just created.&lt;/div&gt;
    
&lt;/div&gt;
</description>
 <pubDate>Sun, 14 Jul 2019 20:43:55 +0000</pubDate>
 <dc:creator>esolitos</dc:creator>
 <guid isPermaLink="false">20 at https://esolitos.com</guid>
</item>
</channel>
</rss>
