Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Wednesday, June 29, 2011

How to install GIT repo in ZyXEL NSA-320

ZyXEL NSA-320 is 1.2GHz NAS box with maximum of 2 x 2T harddisk (SATA I/II only)
The current firmware is 4.01 and is OK for the fun_plug

This box provides a very cheap alternative for the git repo plus your other storage need such as video, music download and backup as well.

You can gain telnet access following the instruction here : http://zyxel.nas-central.org/wiki/FFP-stick

and if you want to install GIT repo in this box, follow these steps.

(1) Follow the instruction here to gain telnet access, enable ssh server in the box, move the ffproot to harddisk and reboot your NAS box
http://zyxel.nas-central.org/wiki/FFP-stick

If you failed the installation, I suggest you to download this directly http://www.inreto.de/dns323/fun-plug/0.5/fun_plug.tgz and put the fun_plug.tgz in your USB stick rather than let it download during setup.

(2) install all packages (as you need most of them to build the git binary) from here
assume your server ipaddress is 192.168.0.10 and use ssh to access the NAS box

ssh root@192.168.0.10
mkdir -p /ffp/pkg
cd /ffp/pkg
rsync -av inreto.de::dns323/fun-plug/0.5/packages .
cd packages
funpkg -i *.tgz


(3) remove dns323 utilities which are not useful for NSA-320
funpkg -r dns323-utils-0.7.176-2.tgz

(4) install PERL & python
cd /ffp/pkg
wget http://www.inreto.de/dns323/fun-plug/0.5/extra-packages/perl/perl-5.10-2.tgz
wget http://www.plord.co.uk/funplug/0.5/python-2.6.4-1.tgz
funpkg -i python-2.6.4-1.tgz perl-5.10-2.tgz


(5) install the build environment
mkdir -p /i-data/md0/ffpbuildenv
cd /i-data/md0/ffpbuildenv
svn co svn://inreto.de/svn/dns323/funplug/trunk .


(6) modify the file chroot.sh to this
chroot.sh Select all

#!/ffp/bin/sh
set -x
CWD=$(pwd)
ffp=$(readlink -f /ffp)
root=/ffp-chroot
if [ -d "$root" ]; then
echo "$root exists"
exit 1
fi

mkdir -p $root
cd $root

mkdir -p ffp dev etc proc sys mnt i-data/md0
mount -t proc proc proc
mount -t sysfs sysfs sys
mount --bind /dev dev
mount --bind /etc etc
mount --bind $ffp ffp
mount --bind /i-data/md0 i-data/md0

ln -s ffp/bin bin
ln -s ffp/lib lib
ln -s ffp/sbin sbin
ln -s ffp usr
ln -s i-data/md0/ffproot/home home

chroot . $SHELL

umount i-data/md0
umount ffp
umount etc
umount dev
umount sys
umount proc

rm bin lib sbin usr home
rmdir ffp dev etc proc sys i-data/md0 mnt
rmdir i-data

cd ..
rmdir $root


(7) chroot to the build environment and get the git source and install it in NAS box

cd /i-data/md0/ffpbuildenv
sh chroot.sh
cd i-data/md0/ffpbuildenv/source
wget http://kernel.org/pub/software/scm/git/git-1.7.6.tar.bz2
tar xjvf git-1.7.6.tar.bz2
cd git-1.7.6
./configure --prefix=/ffp
NO_NSEC=YesPlease make install


(8) after installation of git, exit the build environment

exit


(9) create git repo in the box (from your desktop)

ssh root@192.168.0.10 "mkdir -p /home/root/git/yourproject.git; cd /home/root/git/yourproject.git; git --bare init; touch git-daemon-export-ok"


(10) push your project to the git repo in the NAS box (from your desktop)

cd ~/yourprojectdir
git init
git add . # include everything below ./ in the first commit;
# if you want to remove use git rm -r --cache xxx
git commit
git remote add origin ssh://root@192.168.0.10/home/root/git/yourproject.git
git push origin master


(11) If you don't want to build it. Just download this package and install it using funpkg -i git-1.7.6.tgz However, you still need to have some package dependencies like PERL & python in order to run.

.
.
.

Thursday, November 19, 2009

Install git for Mac OS X Snow Leopard


mkdir ~/src
cd ~/src/
curl -O http://kernel.org/pub/software/scm/git/git-1.6.5.3.tar.bz2
tar -xjvf git-1.6.5.3.tar.bz2
cd git-1.6.5.3
./configure --prefix=/usr/local
make
sudo make install
git --version


This is how to create git-repo over ssh
suppose you have a project in ~/yourprojectdir
and the remote ssh server login is user@xxx.xxx.xxx.xxx
both client and server have git installed

Method 1

cd ~/yourprojectdir

git init

git add . # include everything below ./ in the first commit;
          # if you want to remove use git rm -r --cache xxx

git commit

cd ..

git clone --bare ~/yourprojectdir yourproject.git

touch yourproject.git/git-daemon-export-ok


then copy the git directory to your ssh sever

scp -r yourproject.git user@xxx.xxx.xxx.xx:/Volumes/HD/git/


setup git repo in ssh server

ssh user@xxx.xxx.xxx.xx "cd /Volumes/HD/git/yourproject.git; git --bare update-server-info; mv hooks/post-update.sample hooks/post-update"


check the location of remote git binary and the remote ssh login shell

ssh user@xxx.xxx.xxx.xxx "which git-upload-pack"
ssh user@xxx.xxx.xxx.xxx "echo \$PATH"

mine is /usr/local/bin/git-upload-pack


if the remote login shell does not include path of git, create ~/.bashrc in your remote ssh login shell

ssh user@xxx.xxx.xxx.xxx "echo 'export PATH=\${PATH}:/usr/local/bin' > ~/.bashrc"


push to remote git repo

cd ~/yourprojectdir

git remote add origin ssh://user@xxx.xxx.xxx.xxx/Volumes/HD/git/yourproject.git

git push origin master



Method 2

Create git repo in remote server

ssh user@xxx.xxx.xxx.xxx "mkdir -p /Volumes/HD/git/yourproject.git; cd /Volumes/HD/git/yourproject.git; git --bare init; touch git-daemon-export-ok"


Check the location of remote git binary and the remote ssh login shell as per Method 1

Commit project in your local and push to git repo

cd ~/yourprojectdir

git init

git add . # include everything below ./ in the first commit;
          # if you want to remove use git rm -r --cache xxx

git commit

git remote add origin ssh://user@xxx.xxx.xxx.xxx/Volumes/HD/git/yourproject.git

git push origin master



Test git clone

cd ~
git clone ssh://user@xxx.xxx.xxx.xxx/Volumes/HD/git/yourproject.git working
cd working
git log
git checkout


How to Branch

git branch -r # show branch in repo
git checkout -b todo origin/to-do-branch # checkout a new branch
git checkout master # checkout the master branch

git branch next # create new branch
git add .
git commit -m 'commit nextbranch'
git push origin next



How to fetch Branch from github repo

git clone git://github.com/username/repo-name.git
cd repo-name
git branch -r # show branch in repo
git checkout origin/to-do-branch # quick peek at an upstream branch
git checkout -b todo origin/to-do-branch # checkout a new tracking branch



To fetch a remote from github pull request # into your local repo

git fetch origin pull/<ID #>/head:NEWBRANCHNAME
git checkout NEWBRANCHNAME



Others
git config user.name "yourname"
git config user.email "your email"
git init .
git rebase -i
git commit --amend --author="Author Name "
git diff --stat
git diff --word-diff
git log --pretty='%h %d %s (%cr) [%an]' --graph --all
git config --global alias.lg "log --pretty='%Cred%h%Creset %C(yellow)%d%Creset %s %Cgreen(%cr)%Creset %C(cyan)[%an]%Creset' --graph --all"




For subversion, it is here
http://subversion.apache.org/download/#recommended-release