Looking at the differences between SVN and GIT, it seems that the most significant is pretty much the centralized / decentralized feature - SVN keeps all the code on the server, however you can use your own GIT repository and later commit to the main one.
To install a git server we need the packages git and git-daemon-sysvinit. This is a very basic installation, refer to Git website for the original documentation.
$ sudo apt-get install git-daemon-sysvinit git
To enable the GIT daemon to run in Debian we need to modify the file /etc/default/git-daemon:
GIT_DAEMON_ENABLE=false ----> GIT_DAEMON_ENABLE=true
$ sudo /etc/init.d/git-daemon start
$ sudo /etc/init.d/git-daemon status
[ ok ] git-daemon is running.
$ sudo /etc/init.d/git-daemon status
[ ok ] git-daemon is running.
I currently developing a small Perl script to produce fax reports. I will add the files to my repository. First we initiate a local repository:
$ cd ~/projects/faxreport
~/projects/faxreport$ git init
Initialized empty Git repository in /home/amartin/projects/faxreport/.git/
Initialized empty Git repository in /home/amartin/projects/faxreport/.git/
now we add the files:
$ git add *
Now we commit with a proper description:
~/projects/faxreport$ git commit -m 'Initial FaxReport Release'
[master (root-commit) 36a9ab2] Initial FaxReport Release
Committer: Andreu <amartin@mydomain.com>
3 files changed, 197 insertions(+)
create mode 100755 faxreport.pl
create mode 100644 hylamail.sh
create mode 100644 hylareport.sh
Your name / email details are automatically detected, anyway can modify your identity as follows:
git config --global user.name "Your Name"
git config --global user.email you@example.com
git commit --amend --reset-author
Now, if we want to add the repository to our server we will initiate one with the --shared option (that will arrange for group permissions):
~$ mkdir /opt/git
~$ chgrp -R devgroup /opt/git/faxreport.git
~$ chmod 770 -R /opt/git/faxreport.git
~$ cd [my Fax project folder, in my case $HOME/projects/faxreport]
~$ git clone /opt/git/faxreport.git (will create a new subfolder faxreport)
~$ cp [my files] faxreport/
~$ cd faxreport
~$ git add *
~$ git commit -m 'Initial release'
~$ git push /opt/git/faxreport.git master:master (master is the branch we are using by default)
~$ cd /opt/git/faxreport.git
~$ git update-server-info (needed to do clone via http)
~$ cp [my files] faxreport/
~$ cd faxreport
~$ git add *
~$ git commit -m 'Initial release'
~$ git push /opt/git/faxreport.git master:master (master is the branch we are using by default)
~$ cd /opt/git/faxreport.git
~$ git update-server-info (needed to do clone via http)
Be aware that GIT will use ssh for authentication. From a client computer, we clone the content:
$ git clone amartin@myserver:/opt/git/faxreport.git
Cloning into 'faxreport'...
Verification code:
Password:
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (6/6), done.
$ ls
faxreport
$ ls faxreport/
faxreport.pl hylamail.sh hylareport.sh README.txt
Cloning into 'faxreport'...
Verification code:
Password:
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (6/6), done.
$ ls
faxreport
$ ls faxreport/
faxreport.pl hylamail.sh hylareport.sh README.txt
If we don't want to use SSH, we can point our favorite web server to that folder, and use HTTP to access the repository. For me I changed the default document root in my default lighthttpd installation to the git repository one:
server.document-root = "/opt/git"
And now I can clone my fax scripts using http:
$ git clone http://localhost/faxreport.git
Cloning into 'faxreport'...
Cloning into 'faxreport'...
$ ls faxreport/
faxreport.pl hylamail.sh hylareport.sh README.txt
faxreport.pl hylamail.sh hylareport.sh README.txt
Now we upload a change in README.txt via ssh (works the same for local):
$ git clone amartin@localhost:/opt/git/faxreport.git
Cloning into 'faxreport'...
Password:
remote: Counting objects: 9, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 9 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (9/9), done.$ cd faxreport/
$ vim README.txt
$ git add README.txt
$ git commit -m 'Modified README.txt license details'
[master 19434ad] Modified README.txt license details
Committer: Andreu <amartin@asiarooms.com>
1 file changed, 1 insertion(+)
$ git push
Password:
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 410 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To amartin@localhost:/opt/git/faxreport.git
e48abb5..19434ad master -> master
Done!
$ git clone amartin@localhost:/opt/git/faxreport.git
Cloning into 'faxreport'...
Password:
remote: Counting objects: 9, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 9 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (9/9), done.$ cd faxreport/
$ vim README.txt
$ git add README.txt
$ git commit -m 'Modified README.txt license details'
[master 19434ad] Modified README.txt license details
Committer: Andreu <amartin@asiarooms.com>
1 file changed, 1 insertion(+)
$ git push
Password:
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 410 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To amartin@localhost:/opt/git/faxreport.git
e48abb5..19434ad master -> master
Done!
No comments:
Post a Comment