Reputation: 5203
I'm starting by telling you I'm confused. I know what I think I want to do but I'm not even sure how to go about doing it.
What I think I want to accomplish is to clone a public repo from Github but have that repo be stored on a different machine than the one I'm sitting at.
Or maybe you tell me - ...
There is a public Github repo - a template for a web app (https://github.com/WHMCS/templates-six)
I've tried searching (here, google, github help docs, others) but I think maybe the terminology keeps messing me up and I'm not finding my scenario. Between locals and remotes and clients and repos and forks I've lost my way. Or maybe it's impossible? idk.
I'd appreciate someone explaining how to do this if it can be or, if it's really just simple/basic stuff, then just point out please the right terminology at each end and I'll go back to searching it out.
Or maybe I've really scrambled it all in which case suggest a way to approximate the end result.
Thanks
Upvotes: 0
Views: 3014
Reputation: 83527
I suggest that you read the first three chapters of Pro Git. It is free online and covers the majority of commands you need to perform tasks like this. It isn't very long. Just read a little every day and before you know it, you'll be a Git master. Eventually, you will also need to read some in the later chapters about using git on the server.
Upvotes: 0
Reputation: 17292
This is actually pretty straightforward with Git. There are many ways to do it; here is what I would do:
git clone [email protected]:WHMCS/templates-six.git
cd templates-six
. From here on out, we'll be running our git commands inside this repository folder.origin
. For clarity, we're going to rename it. Run git remote rename origin github
git init --bare foobar.git
.git remote add webserver ssh://[email protected]:/home/joelaz/foobar.git
master
branch up to the webserver. git push webserver master:master
. If that doesn't work for some reason, it should be safe to try -f
, since there's no history you care about on the remote server.git branch -u webserver/master
. Now, by default, git push
will push to your webserver.With this setup, whenever you want to get updates from Github, you can git fetch github
and then git merge github/master
, which merges github
's master branch into your own local master branch. Finally, as before, git push
sends it to your webserver. You'll have to maintain the code on your workstation (which is probably a good idea anyway), and you'll make changes and fix merge conflicts there before pushing the code to webserver
with git push
.
To help you understand what's happening, keep in mind that each of the 3 repositories (Github, workstation, server) maintains its own copy of the code, and it's own copy of any branches. You move code between the repositories by pulling and pushing from the repository on your workstation.
Upvotes: 11