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
Blackjack Written in C using SDL
Console Blackjack Written in C
Console Blackjack Written in Perl 6
How-to build latest Linux kernel from Linus' git repo on Debian/Ubuntu
Console Blackjack in C++
apache (1) bash (2) bashrc (1) blackjack (5) c (2) c11 (1) callproof (1) clang (3) console (4) cpp (1) data (1) debian (3) diff (1) django (2) games (1) gcc (3) git (2) github (1) gitlab (5) gmail (1) go-lang (3) google (1) gourse (1) kernel (3) latin1 (1) linux (3) lottery (1) module (1) mongodb (1) mp3s (1) mutt (1) patch (1) perl6 (1) postgresql (2) powerball (1) psql (1) python (2) raspberrypi (1) sdl (1) sed (1) testing (1) ubuntu (1) utf8 (1)

Copyright © 2018 · GregDonald.io · All Rights Reserved