If you want to leave Github for whatever reason, you probably want to take all your code with you, and all your history and branches, etc.

Here's an example for how I moved my Android Eclipse workspace from Github to my own remote server.

First I make a new git repo on my remote server:

$ git --bare init ~/git/workspace

The --bare option means I'm not going to work on the code in the remote git repo directly.

Next I push my current local 'master' to the new repo:

$ git checkout master
$ git push ssh://me@myserver.com/git/workspace master

After that I push my working branch:

$ git checkout work
$ git push ssh://me@myserver.com/git/workspace work

You could repeat this step if you have more branches.

I created my local repo using 'clone' so it has an 'origin' remote branch defined. This 'remote' branch is where git fetches and pushes changes.

Right now my 'fetch' and 'push' remote origins point to Github:

$ git remote -v
git@github.com:gdonald/workspace.git (fetch) origin
git@github.com:gdonald/workspace.git (push)

So I remove my 'origin' and add the new one:

$ git remote rm origin
$ git remote add origin ssh://me@myserver.com/git/workspace

Then I update my local master's 'remote' to the new 'origin':

$ git config branch.master.remote origin
$ git config branch.master.merge refs/heads/master

After this change I can automatically push my commits to the new repo, 'origin' is now selected as my default 'remote' for 'master' :)

$ git remote -v
ssh://me@myserver.com/git/workspace (fetch) origin
ssh://me@myserver.com/git/workspace (push)
$ git push
$ git pull

   Recent articles
Console Blackjack written in Perl 6
How-to build latest Linux kernel from Linus' git repo on Debian/Ubuntu
Console Blackjack in C++
.rubyocop.yml
Visual Studio Code Configuration
   Tags
airplane (1) apache (1) apple (1) bash (2) bashrc (1) blackjack (3) callproof (1) college (1) config (1) console (3) cpp (1) data (1) debian (4) diff (1) django (2) electoral (1) enterprise (1) flying (1) freebsd (1) games (1) git (3) github (4) gmail (1) go-lang (3) google (1) gourse (1) kernel (3) latin1 (1) linux (4) lottery (1) microsoft (1) module (1) mongodb (1) mp3s (1) mutt (1) patch (1) perl6 (1) photos (1) postgresql (2) powerball (1) psql (1) python (2) raspberrypi (1) rc (1) rubocopyml (1) sed (1) stack (1) sublime (1) testing (2) trace (1) ubuntu (2) utf8 (1) virus (1) visualstudiocode (1) vote (1) waylon (1)
   Twitter

Copyright © 2017 · GregDonald.io · All Rights Reserved