Tuesday, May 27, 2014

How to create remote git repo from local project

1. create files/projects/etc.
2. cd into the directory and run
    git init

3. add all of your files into git
    git add *

4. commit it
    git commit -m "Initial commit"

5. for kicks, run following command to see if you have any attached remote repos. you should not see anything
    git remote

< see below "On your remote server" section >

6. Attach remote repo
    git remote add origin ssh://user@ip.add.re.ss:22/opt/git_repos/foo-project.git

7. if you mess up, run
    git remote remove origin

8. now run #5 command and you should see origin there

9. now push your local changes to repo for everyone to see
    git push -u origin master

10. after that, you can just call
    git push

On your remote server
a. sudo su -
b. cd <path_to_git_repos>
c. mkdir foo-project.git
d. cd foo-project.git
e. git init --shared=777 --bare
if you wont specify --shared=777 you wont be able to write to it due to permission issues. If you are stuck on Writing object part during your git push, that's the reason.

Reference:
http://qugstart.com/blog/ruby-and-rails/create-a-new-git-remote-repository-from-some-local-files-or-local-git-repository/

No comments:

Post a Comment