gentoo上安装git
# USE=”-dso” emerge -av dev-vcs/git
# emacs /etc/conf.d/git-daemon
GITDAEMON_OPTS=”–syslog –enable=upload-pack –enable=upload-archive –enable=receive-pack –export-all –base-path=/opt/git /opt/git”
#chown nobody.nobody /opt/git
gentoo上安装git
# USE="-dso" emerge -av dev-vcs/git
# emacs /etc/conf.d/git-daemon
GITDAEMON_OPTS="--syslog –enable=upload-pack –enable=upload-archive --enable=receive-pack --export-all --base-path=/opt/git /opt/git"
#chown nobody.nobody /opt/git
# sudo -u nobody -s
$ cd xmapps.git/
$ git --bare init
' git使用教程
http://desizen.com/freebies/git-and-github-tutorials/
http://blog.prosight.me/index.php/2009/11/485
http://www.kernel.org/pub/software/scm/git/docs/v1.7.4.5/git.html
第一个要配置的是你个人的用户名称和电子邮件地址。这两条配置很重要,每次 Git 提交时都会引用这两条信息,说明是谁提交了更新,所以会随更新内容一起被永久纳入历史记录:
$ git config --global user.name "wang chao"
$ git config --global user.email wangchao@domain.com
$ git config --global core.autocrlf true
$ git config --global core.safecrlf true
如果是windows
$ git config --global core.autocrlf false
修改gitconfig
[user]
email = wangchao@domain.com
name = wangchao
$ d:\dev\rails\RailsInstaller\Git\bin\ssh-keygen.exe -f "%homedrive%%homepath%\.ssh\id_rsa" -C 'wangchao@domain.com' -t rsa
然后到远程主机上
cat id_rsa.pub >> /home/wch/.ssh/authorized_keys2
查看你的配置 在项目下还可以看见项目的配置
$ git config --list
比如
core.symlinks=false
core.autocrlf=false
color.diff=auto
pack.packsizelimit=2g
help.format=html
http.sslcainfo=/bin/curl-ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
user.name=wang chao
user.email=wangchao@domain.com
项目下的配置
core.symlinks=false
core.autocrlf=false
color.diff=auto
pack.packsizelimit=2g
help.format=html
http.sslcainfo=/bin/curl-ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
user.name=wang chao
user.email=wangchao@xiaoma.com
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.hidedotfiles=dotGitOnly
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=git://www.xiaoma.com/xmapps
branch.master.remote=origin
branch.master.merge=refs/heads/master
也可以直接查阅某个环境变量的设定,只要把特定的名字跟在后面即可,像这样:
$ git config user.name
Scott Chacon
想了解 Git 的各式工具该怎么用,可以阅读它们的使用帮助,方法有三:
$ git help
$ git
$ man git-
比如,要学习 config 命令可以怎么用,运行:
$ git help config
从本地代码创建仓库
$ git init
初始化后,在当前目录下会出现一个名为 .git 的目录,所有 Git 需要的数据和资源都存放在这个目录中。不过目前,仅仅是按照既有的结构框架初始化好了里边所有的文件和目录,但我们还没有开始跟踪管理项目中的任何一个文件。(在第九章我们会详细说明刚才创建的 .git 目录中究竟有哪些文件,以及都起些什么作用。)
如果当前目录下有几个文件想要纳入版本控制,需要先用 git add 命令告诉 Git 开始对这些文件进行跟踪,然后提交:
$ git add *.c
$ git add README
$ git commit -m "initial project version"
检查当前文件状态
要确定哪些文件当前处于什么状态,可以用 git status 命令。如果在克隆仓库之后立即执行此命令,会看到类似这样的输出:
$ git status
# On branch master
nothing to commit (working directory clean)
添加一个远程版本库
$ git remote add pb ssh://wch@www.domain.com:22229/opt/git/xmapps.git
看看已有的远程仓库
$ git remote -v
origin git://github.com/schacon/ticgit.git
查看本地分支
$ git branch
推送到远程库pb
$ git push pb master
删除远程库
$ git remote rm pb
查看远程库
$ git remote show pb
端口问题
在.ssh/下添加config文件
添加
host www.xiaoma.com
hostname www.xiaoma.com
port 22229
' fatal: Unable to create temporary file: Permission denied错误
# chown -R wch /opt/git
# chmod -R u+rw /opt/git/
' 取出代码库的数据
git clone ssh://wch@www.domain.com:22229/opt/git/xmapps.git
' 从仓库更新
$ git fetch origin
$ git merge origin/master
' fatal: LF would be replaced by CRLF in README错误
如果是windows
$ git config --global core.autocrlf false
参考http://blog.csdn.net/gracioushe/archive/2011/03/21/6266137.aspx