ubuntu git 服务器环境搭建

来源:互联网 发布:vue.js和jquery 编辑:程序博客网 时间:2024/05/29 09:41

1. 安装git服务

sudo apt-get install git-core openssh-server openssh-client
sudo apt-get update
sudo apt-get install python-setuptools
git config --global user.name "hh"
git config --global user.email "XXXX@qq.com"
git clone https://github.com/res0nat0r/gitosis.git
cd gitosis/
python setup.py install


2. 增加用户  
sudo useradd -m git  
sudo passwd git  




3. git的本地管理
3.1 创建分支   
git branch dev
3.2 删除分支
git branch -d dev
3.3 切换到master 分支
git checkout master
创建并切换到dev
git checkout -b dev
3.4 查看当前已有分支
git branch
3.5 合并分支(dev合并到master)
    git merge dev master
3.6 创建本地分支,切换本地分支, 提交分支
git branch 1.0
git checkout 1.0
git push -u origin 1.0

3.6.1 提交本地分支

3.7 本地提交(test1.txt)
git commit test1.txt


4. git的远程管理
4.1 clone git库到本地
git clone 192.168.80.129:/home/git/myRep.git
4.2 切换分支
git checkout -b dev

4.3 clone 远程git仓库到本地,默认只clone master分支
git clone git@github.com
4.4 创建远程dev分支到本地
git checkout -b dev origin/dev