树莓派3B+ Git服务

树莓派3B+ Git服务


Git是一个很棒的代码管理仓库。


1.安装Git服务

sudo apt-get install -y wget git-core

// 添加一个 git 用户和组
adduser --system --shell /bin/bash --gecos 'git version control by pi' --group --home /home/git git

// 更改密码:
passwd git

2.初始化项目仓库

可选方法一:新建一个空的仓库

// 增加一个空的Git仓库(Git Repository)
su git
cd ~

// 初始化并清空仓库。
mkdir test.git
cd test.git
git --bare init

可选方法二:直接克隆github的项目到服务器

git clone https://github.com/xiaanming/SlideCutListView.git ~/github.git

3.下拉项目

如果你想要测试一下,试着clone你的仓库到你的Windows机器上。首先更改路径到你希望存储clone的地方(一个空文件夹),然后通过命令行(或git bash),运行:

git clone git@192.168.1.120:~/test.git

4.上传项目(提交修改)

// Push你的代码到Pi上
git remote add pi git@192.168.1.120:~/test.git

// 现在你要做的就是add你的代码,commit然后push。
git add .
git commit -am "初始化代码"
git push pi master

// 如果你得到了一个类似这样的消息”authenticity of host …”只需要输入”yes”然后继续就可以了。

猜你喜欢

转载自blog.csdn.net/kxwinxp/article/details/78852349