1

I recently bought a Raspberry Pi. I finished installing and setting up SSH and Git on the Raspberry Pi. I am able to make connections and to transfer files using ssh and scp respectively.

I am using a 16 GB USB drive to store data which is mounted on /media/data.

I have several repositories on GitHub. I want to migrate those repositories to my Raspberry Pi such that each time I use git push, all commits are pushed to my Raspberry Pi.

For example, I own this repository on GitHub:

https://github.com/cfbaptista/PolyMath.jl

I push to this repository from my laptop by running:

$ cd /home/carlos/Workspace/PolyMath.jl/
$ git push

However, instead of pushing to GitHub I want to push to:

raspberrypi:/media/data/repos/git/PolyMath.jl

How do I perform the necessary changes?

P.S.: Momentarily, my Raspberry Pi is accessible only on my own local network. External access has not been set up yet.

Matthias Braun
  • 32,039
  • 22
  • 142
  • 171
Aeronaelius
  • 1,291
  • 3
  • 12
  • 31
  • The setup I would like to have eventually is: laptop > raspi > GitHub. I will be using GitHub only to reach out to the rest of the world. However when I am really in dev mode I only want to push to my raspi. So assume several pushes a day to my raspi and only one push to GitHub in 1 - 3 months. – Aeronaelius Dec 30 '13 at 07:40
  • @janos In case I want to abandon Github after pushing my code to Raspi, what should I do? – reFORtEM Aug 29 '17 at 14:53

2 Answers2

2

You need to add a new remote which points to the new repo on your Raspberry Pi, see this article on adding remotes.

E.g.

git remote add pi **url-to_new-repo**
git push pi master

The first command sets up a new remote pi, while the second pushes your master branch to pi.

If you want to make a branch push to a remote automatically, you can set it as a remote tracking branch. See this question for more details:

How do I change the remote a git branch is tracking?

Community
  • 1
  • 1
ColinE
  • 68,894
  • 15
  • 164
  • 232
0

Log into your Raspberry Pi and do

$ git clone --mirror https://github.com/cfbaptista/PolyMath.jl polymath.git

This will create a bare repository containing a full "mirror clone" which would work exactly as the repository at github, just the repo URL will be different.

To "redirect" the local repository on your workstartion, use git remote add ... as suggested by ColinE.

The access itself to the repository is the trickiest part but it's out of the scope of this question — search SO for questions dealing with Git hosting.

kostix
  • 51,517
  • 14
  • 93
  • 176