Simple git setup and remote transfer
First we want to initialize a new repository on our local machine and then commit the source.
|
1 2 3 4 5 |
$ git init $ git add . $ git commit -m 'Initial commit of the blog.' [master (root-commit) 87f3b95] Initial commit of the blog. 1034 files changed, 262684 insertions(+), 0 deletions(-) |
After that we create a so called bare repository to be able to copy it to our server.
|
1 2 3 4 |
$ cd .. $ git clone blog blog.git --bare Cloning into bare repository blog.git... done. |
Let’s make a tarball and compress it. After that we upload it onto our server with the scp command.
|
1 2 |
$ tar cvjf blog.tar.bz2 blog.git $ scp blog.tar.bz2 yourserver:/home/yourusername/git/ |
Then we log on to our server and untar our package:
|
1 2 |
$ tar xvjf blog.tar.bz2 $ rm blog.tar.bz2 |
Now our repository is located on the server — ready to reference it now.
Back to our local machine we are going to tell git that the repository is now a remote one:
|
1 2 3 4 5 6 |
$ git remote add origin yourserver:~/git/blog.git $ git config --global branch.master.remote origin $ git config --global branch.master.merge refs/heads/master $ git pull From yourserver:~/git/blog * [new branch] master -> origin/master |
Et voilĂ . Now you can submit your changes to the remote repository via git push.
Another advantage of this is that you can do your deployment with an easy git pull on your remote server.