Thursday, February 4, 2010

GIT Howto sync to remote via push?

From CVS to SVN, and now GIT.
Git is the latest version control system created by Linus,
a big applause to him, one of opensource greatest gurus and leader :)

How to use?
1st, local:
cd to your source directory
type:
git init
git add .
git commit

next, ssh into your remote host,
example: /home/myname
mkdir mygit
cd mygit
git init
git config --bool core.bare true

go back to local source directory
type:
git push ssh://myname@[host]:port#/home/myname/mygit master
git config remote.origin.url ssh://myname@[host]:port#/home/myname/mygit

Done!
Updates: mar 3, 2011:
Later version of git forbids pushing an existing git.
So, you may just upload the .git directory from your local source directory to remote directory:
Example /home/myname/mygit/.git -> (remote) /home/myname/mygit/.git
Next, run git config --bool core.bare true (on remote machine)
Then, you may run git config to setup the git default push and pull on local machine.
Both copy shall have the same version :)

So if you ever want to push to remote again, simply type:
git push

And to update, type:
git pull

And if you are sharing this git with someone else to commit, you may set it to :
git config core.sharedRepository true

And make sure all users of the git should have the same group name.

To add a user to the git:
/usr/sbin/useradd -g groupname newusername
sudo passwd newusername

next, set the permission to the git directory on remote
chmod g+w -R .


Reference:

No comments: