- git installation in linux:
http://git-scm.com/downloads download sw package
$tar -zxvf git-1.8.5.tar.gz
$cd git-1.8.5
$./configure
$make
$sudo make install
- git installation in windows:
msysgit是 Windows版的Git ,从http://msysgit.github.io/ 下载,然后按默认选项安装即可。
安装完成后,在开始菜单里找到 “Git”->“Git Bash” ,蹦出一个类似命令行窗口的东西,就说明 Git安装成功!
- git configuration:
$git --version
$git config --global user.name "xiaopili"这里用你的用户名
$git config --global user.email " [email protected] "这里用你的邮箱
强制策略挂钩配置
参考http://git-scm.com/book/zh git 强制策略实例
你应该在每次提交前核查你的提交注释信息,这样你才能确保服务器不会因为不合条件的提交注释信息而拒绝你的更改。为了达到这个目的,你可以增加 ‘commit-msg‘挂钩。如果你使用该挂钩来阅读作为第一个参数传递给 git的提交注释信息,并且与规定的模式作对比,你就可以使 git在提交注释信息不符合条件的情况下,拒绝执行提交。
$ curl -o .git/hooks/commit-msg http://hzgitv01.china.nsn-net.net/tools/hooks/commit-msg
$ chmod u+x ./.git/hooks/commit-msg 这两个命令不敲就没有change-id
$ echo "* -text"> .git/info/attributes #为了解决 dos环境下跟 unix的转换问题 - 回车和回车换行,windows和linux的区别。
- 本地与 git 远程仓库间传输是通过 SSH加密的话,需要创建 SSH key.
[[email protected] ~]# ssh-keygen -t rsa -C "[email protected]"这里用你的邮箱
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
6c:59:8d:e9:ed:f6:ee:6d:fc:c4:22:d5:2d:83:48:da [email protected]
[[email protected] ~]# cat /root/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAsqPwmzVK0Pmmi4RLjFxMOeveGIRi8qdHpqxz7hBDRQP+KcIdp9LhqaCiTDXpyCr7wbnjtnzBfykbsdj4sRoAWagvYMY5TqMCmCLurjaaCmU9E2B+nMCCmr9n8AmeTOf7qQHUtM1ZQKc0lT8RZVkwkhP
1tcAz8g045oyon1FM2lsUzmFYzqfKhk6NhXYxaIf4ONW0FhrSv+xO8VAiYF7B42uVyGnbNbwUxHLWPIGb9Sqcn0Kog2vJYn0n3oT8QukPNFrT3zg3oFFBTa0mVG2CtymIVdl1FGtUv+rWGPd0N7glPFZ7GU8dl7Kci3hssFnW17+Z6GKQIHOKgVga14
OHZw== [email protected]
Add to http://hzgitv01.china.nsn-net.net/#/settings/ssh-keys
- 从远程库克隆一个本地库
[[email protected] ~]# git clone ssh://[email protected]:29418/scm_il/SS_ILFT
如果已经有了,则 git reset --hard HEAD 来放弃所有本地修改
- 显示分支
[[email protected] ~]# git branch #本地
[[email protected] ~]# git branch -r #远程
[[email protected] ~]# git branch -a #所有
- 在本地创建和远程分支对应的分支 ,并切换到该分支
[[email protected] ~]#$ git checkout origin/R_IL_14.6.1.0 -b 1406xx
( git checkout origin/VirtualTrunk -b virt )
git checkout origin/cloud_controller_dev -b cloudzt
在.git/config中会加入如下变量配置
[branch "1406"]
remote = origin
merge = refs/heads/R_IL_14.6.1.0
对于已经存在的分支,直接用 git checkout 1406即可完成切换动作
- 你的修改
- [[email protected] learngit]# git add readme.txt
- [[email protected] learngit]# $git commit #log 内容需要用http://ipascmci.china.nsn-net.net/svnlogtemp/ 生成
- [[email protected] learngit]# git pull --rebase origin refs/heads/${targetbranch}
- [[email protected] learngit]# $git push origin HEAD:refs/for/${targetbranch}
- Ask Review+verify from others under link http://hzgitv01.china.nsn-net.net , and Rebase if Necessary