## centos 換yum為阿里云的源
### 1、備份
`mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup`
### 2、下載新的CentOS-Base.repo 到/etc/yum.repos.d/
#### CentOS 5
`wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo`
`或者`
`curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo`
#### CentOS 6
`wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo`
`或者`
`curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo`
#### CentOS 7
`wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo`
`或者`
`curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo`
### 3、之后運行yum makecache生成緩存
## 相關鏈接
* [官方主頁: http://www.centos.org/](http://www.centos.org/)
* [郵件列表: http://www.centos.org/modules/tinycontent/index.php?id=16](http://www.centos.org/modules/tinycontent/index.php?id=16)
* [論壇: http://www.centos.org/modules/newbb/](http://www.centos.org/modules/newbb/)
* [文檔: http://www.centos.org/docs/](http://www.centos.org/docs/)
* [Wiki: http://wiki.centos.org/](http://wiki.centos.org/)
# 自建git
由于碼云項目出了企業版 每個項目成員最多5個人。
雖然coding允許免費5個私有項目,為了不受限制,我們決定阿里云服務器上自建git倉庫。
1.安裝
yum install git git-daemon
2. 配置 Git
在 CentOS 中,Git 是以 xinetd 方式提供服務的,默認的 xinetd 配置文件在:/etc/xinetd.d/git。
編輯配置文件,以下是改好的一份 git xinetd 配置文件:
~~~
# default: off
# description: The git d?mon allows git repositories to be exported using \
# ? ? ? the git:// protocol.
service git
{
? ? disable = no
? ? ? ? socket_type ? ? = stream
? ? ? ? wait? ? ? ? ? ? = no
? ? ? ? user? ? ? ? ? ? = nobody
? ? ? ? server? ? ? ? ? = /usr/libexec/git-core/git-daemon
? ? ? ? server_args ? ? = --base-path=/var/lib/git --export-all --user-path=public_git --syslog --inetd --verbose
? ? ? ? log_on_failure? += USERID
}
~~~
接下來啟動 xinetd 服務:
[root@c1.inanu.net]#
`service xinetd start`
3. 建立 Puppet 服務器端 Git 倉庫
~~~
[root@c1.inanu.net]#?useradd -d /var/lib/git -s /usr/bin/git-shell git #創建 git 用戶
[root@c1.inanu.net]#?passwd git #設置 git 用戶密碼
[root@c1.inanu.net]#?chown -R git:git /var/lib/git
[git@c1.inanu.net]$?cd /var/lib/git
[git@c1.inanu.net]$?mkdir .ssh
[git@c1.inanu.net]$?chmod 700 .ssh
[git@c1.inanu.net]$?touch .ssh/authorized_keys
[git@c1.inanu.net]$?chmod 600 .ssh/authorized_keys
[git@c1.inanu.net]$?mkdir /var/lib/git/xx.git #創建 Puppet 服務器端 Git 倉庫
[git@c1.inanu.net]$?sudo chown -R git:git xx.git
[git@c1.inanu.net]$?cd /var/lib/git/xx.git 注意是否是git的權限
[git@c1.inanu.net]$?git --bare init #初始化 Puppet 服務器端 Git 倉庫
~~~
4.客戶端clone
`git clone git@ip:xx/path 全路徑`
已有項目如何遷移
1. 本地clone? 剛建的項目
2. 拷貝本地已有項目所有文件 到這個目錄后提交
3. 設置遠程項目 remote 為新的地址
4. 嘗試更新
更新 賬戶密碼??git git2018
查看遠程地址
~~~
Git remote -v
git remote set-url origin?ssh://git@116.62.11.197:58585/home/git/ws.git
~~~
無法加入know_hosts?
1. chown?username:?/home/username/.ssh??
2. chown?username:?/home/username/.ssh/*??
3. chmod?700?/home/username/.ssh??
4. chmod?600?/home/username.ssh/*??
