0

I have an existing website hosting on dedicated server and I now want to setup the site to be backed up onto Github. So I created an account on github.com and created the repo lets call it websitea.com now my question is is there a way I can push the website files from the website server into the github repo without first downloading the entire site to my local machine and then using netbeans or some other IDE to push it up to github?

Yes I am new to using Git and trying to learn it. My goal is to get the entire site into the github repo and then use netbeans as my IDE to pull down some files I want to work on then I am thinking I would create a branch and upload the newly edited files to that branch on github and then merge them with the master once we have a few edited files that have been reviewed and are ready to be merged. Is my workflow sound correct?

So I ssh (via putty) into the dedicated server that hosts the website I want to backup into the Github repo. Once ssh'ed in I do the following commands:

eval "$(ssh-agent -s)" that gets me the below output Agent pid 10019

I then type ssh-add ~/.ssh/id_rsa I then type cat ~/.ssh/id_rsa.pub because the pbcopy command does not seem to work I then copy and paste that key that is shown into the github key text box to add that key to github and I give it a name "my desktop key"

I then go back to putty and type git remote add origin https://github.com/xxx/xxx.git of course replacing the x'es with the correct values and I get a fatal: remote origin already exists message but thats ok

I then type git push -u origin master and am still getting the Permission denied (publickey). message ???

Jayreis
  • 253
  • 1
  • 7
  • 28

2 Answers2

1

My goal is to get the entire site into the github repo and then use netbeans as my IDE to pull down some files I want to work on then

Open a new repository in git hub and follow the instruction of the page.
As you can see in the image below you will get all the info you need.

enter image description here


Is my workflow sound correct? Sounds good, also checkout the gitflow

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • Ok so using Putty I am ssh'ing into the dedicated server I have with Rackspace (where the website is hosted) I then cd into the dir where the actual website files are. I then do git remote add origin git@github.com:xxxxx/www.xxxx.com.git of course the ''x'' are replaced with the gituser and domain I then type in git push -u origin master but I then am presented with Permission denied (publickey).so how do I add my publickey to putty? – Jayreis Jan 13 '16 at 14:11
  • Read this out: http://stackoverflow.com/questions/34634132/managing-two-ssh-keys/34634893#34634893 – CodeWizard Jan 13 '16 at 15:00
1

is is there a way I can push the website files from the website server into the github repo without first downloading the entire site to my local machine

I think that to push from a remote web server to github, you need to be able to ssh into that machine:

ssh your-user-name@your-web-server 

Once you ssh into the machine you need to do the following:

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
pbcopy < ~/.ssh/id_rsa.pub

Add the copied key to Github by following these instructions

git remote add origin https://github.com/<your-github-username>/<repository-you-created>.git
git push -u origin master

My goal is to get the entire site into the github repo and then use netbeans as my IDE to pull down some files I want to work on then

Github does not work by checking out individual files from the repository, making changes to them and then submitting that "changeset". In CVS like perforce is easy to do partial checkouts, while it is currently next to impossible in Git. You need to clone the entire repository from github, then make changes to the files you want and commit them to github

deborah-digges
  • 1,165
  • 11
  • 19
  • @user1739740 You need to generate an ssh key and associate it with your github account: https://help.github.com/articles/generating-ssh-keys/ – deborah-digges Jan 13 '16 at 14:25