1

I set up my own Git repository on my own server, and created a repository. I am new to Git, and all I do at the moment is git add *, git commit, and git push. I am not all that familiar with git.

Now, I would love to create a repository on Git Hub, so that the remote GitHub repository has the same list of changes I have on my own server.

I don't suppose you could give me a list of steps, as well as an explanation of what each step will do? My main concern is that I don't want to ruin my current repository.

UPDATE: Thank you everybody. I still don't quite get how GIT works (I am sure I will at some point), but: https://github.com/mercmobily/hotplate :D

Merc
  • 16,277
  • 18
  • 79
  • 122

4 Answers4

2

Don't have time to write a full solution, but basically you need to:

# create a nickname for your github account. In this case it is github
git remote add github your-github-repo-path

Keep committing the changes locally and pushing them. When you want to push also to github, execute:

#push the changes to the repo on the 'github' nickname, to the branch master
git push github master
Carlos Campderrós
  • 22,354
  • 11
  • 51
  • 57
  • Yes but this way will the full patch history "transfer" to GitHub? – Merc Aug 30 '12 at 15:40
  • what do you mean by full patch history? If you have just setup a new project and expecting files to have revision before you setup git on you project then no. If you mean if this way you can make sure that all your files and their logs and previous revisions are also transfered to github then yes. this would work fine. – ro ko Aug 30 '12 at 15:47
  • @Merc yes your github repo will have the same records (commits, logs, ...) as your local repo – Carlos Campderrós Aug 30 '12 at 15:54
  • I am getting "error: failed to push some refs to 'https://github.com/mercmobily/hotplate.git' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes (e.g. 'git pull') before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details. Help...? – Merc Aug 30 '12 at 16:07
  • 1
    When you see this error that means that the repo you are pushing to has new commits that you don't have in your local copy. So probably your github repo has some content (the README.md file maybe) that has been committed. You need to do a `git pull github master` and after that, you will be able to push. – Carlos Campderrós Aug 30 '12 at 16:12
  • Accepted this one because it had the immensely useful tip of adding "github" as a nickname...Thanks! – Merc Aug 31 '12 at 01:19
1

Here's something that might help GIT_HOW_TO But I believe there are just too many resources on the internet that would help you do it. Steps to setup your repo on github is well mentioned on their Help_Page Please go throught this and if you have any question feel free to ask. BTW Welcome to Git :)

ro ko
  • 2,906
  • 3
  • 37
  • 58
  • Shall I tick "Initialize this repository with a README" when I create the repo in GitHub? – Merc Aug 30 '12 at 15:38
  • If you need it :) It is supposed to create a simple readme file where you can write details about your project/repository which can be visible when people/yourself view the project in github. For eg: https://github.com/rohankoid/zdmfg Here details, Zend-Db-Model-Form-Generator ---------------------- Instructions: 1. copy config.php-default to config.php inside data directory ... ' are all written inside readme.txt file and can act as a summary of the project and its purpose. – ro ko Aug 30 '12 at 15:44
1

Create a new repository on GitHub, as here: https://help.github.com/articles/creating-a-new-repository

Then do steps 4 and 5 from here: https://stackoverflow.com/a/8012698/705048

Community
  • 1
  • 1
hcarver
  • 7,126
  • 4
  • 41
  • 67
  • Shall I tick "Initialize this repository with a README" when I create the repo in GitHub? – Merc Aug 30 '12 at 15:37
  • I think not, for now. It's just slightly easier if the repo starts empty. You can always add one later. – hcarver Aug 30 '12 at 15:46
  • Ugh I did add it... Now I am getting "error: failed to push some refs to 'https://github.com/mercmobily/hotplate.git' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes (e.g. 'git pull') before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details. " – Merc Aug 30 '12 at 16:08
  • Did you try a `git pull`? If you pull and merge the changesets there into what you already have (which will just insert the README file into your codebase), you should then be able to commit that and push. – hcarver Aug 30 '12 at 16:10
  • Great, no problem! If I have been helpful, then an upvote / accepting the answer would be much appreciated! – hcarver Aug 30 '12 at 21:04
  • No worries, I always upvote useful things and accept answers (although this one is a tough call...!) – Merc Aug 31 '12 at 01:18
1

Create a repository and add your remote path to your local machine

In your local machine switch to remote git path

cd ../../../

git pull "name " master 

pwd:"enter your password"

git add Filename

git commit -m "Comments on files"

git push "name" master

i hope this could help you , correct me if 'm worng

thar45
  • 3,518
  • 4
  • 31
  • 48
  • 1
    Shall I tick "Initialize this repository with a README" when I create the repo in GitHub? – Merc Aug 30 '12 at 15:38