git

    avoid committing git conflicts

    14 Nov 2011

    I made a mistake when merging branch last week, I forgot to remove a conflict syntax "<<<<<< HEAD" and push it to remote repository. It breaks other one's development. So stupid to make such mistake.

    To avoid making such mistake anymore, I write a git hook .git/hooks/pre-commit to check conflict syntax "<<<<<<" and ">>>>>>"

    #!/usr/bin/env ruby
    
    `git diff-index --name-status HEAD`.split("\n").each do
    |status_with_filename|
      status, filename = status_with_filename.split(/\s+/)
      next if status ==...
    Read More

    Tags 


    git for hostmonster

    02 May 2010

    前段时间对网站做了些更新,于是在本地修改了代码,再git push,谁知却得到bash: git-receive-pack: command not found的error,我的git repository是放在hostmonster服务器上面的,之前都是正常的,于是提交ticket给hostmonster的support,得到的答复是他们升级的openssh,通过git+ssh不会再读取.bashrc或.ssh/environment文件,也就是说通过git+ssh没有办法修改PATH了。

    没办法了,只能手动将命令的路径补全了,对于git pull/git ps来说,只需要在输入命令的时候增加参数,比如

    git clone --upload-pack=/home1/huangzhi/git/bin/git-upload-pack
    git push --receive-pack=/home1/huangzhi/git/bin/git-receive-pack

    不过每次都输入参数实在麻烦,直接写到配置文件.git/config

    [remote "origin"]
    uploa...
    Read More

    Tags 


    Move google svn to github git

    19 Sep 2009

    之前contactlist这个项目一直放在google code上面,今天把contactlist移植到了github上。记录下移植的过程:

    首先是用git-svn把googlecode上的项目checkout出来

    git svn clone https://contact-list.googlecode.com/svn -T trunk -b branches -t tags

    之后就是push到github了

    git remote add origin git@github.com:flyerhzm/contactlist.git
    git push origin master

    相当简单,这下我的项目就都搬到github上面去了

    Read More

    Tags 


    在hostmonster上搭建git server

    14 Jun 2009

    hostmonster本身并不支持git,不过还好它提供了ssh,我们可以ssh上去编译git。

    首先,ssh到hostmonster上,编译安装git

    $ mkdir git
    $ cd git
    $ wget http://kernel.org/pub/software/scm/git/git-1.6.3.2.tar.gz
    $ tar -zxvf git-1.6.3.2.tar.gz
    $ cd git-1.6.3.2/
    $ ./configure --prefix=$HOME/git
    $ make  make install

    修改~/.bashrc,设置环境变量

    export GIT_HOME=$HOME/git
    export PATH=$GIT_HOME/bin/:$GIT_HOME/lib/libexec/git-core/:$PATH

    验证结果

    $ source ~/.bashrc
    $ git --version

    我们在本地新建一个rails app来使用git server

    $ rails home -d mysql
    $ cd home
    $ git ...
    Read More

    Tags 


    设置git全局忽略的文件

    11 Jun 2009

    现在家里的笔记本一直用vim开发rails项目,再用git作版本控制,往往碰到这样的问题,在一个窗口用vim开发,再另一个窗口git status查看的时候,总是有vim生成的.swp文件干扰,每次都加在项目的.gitignore文件里也麻烦,于是就将其配置在git的全局变量中。

    新建~/.gitignore文件:

    .DS\_Store
    *.swp

    然后执行:

    $git config --global core.excludesfile ~/.gitignore

    再执行git status,好干净啊!

    Read More

    Tags