初始化项目:
1、生成github密钥对并配置远程仓库
$ git config --global user.name "您的github姓名"
$ git config --global user.email "您的邮箱"
$ ssh-keygen -t rsa -C "your_email@youremail.com" #会提示你输入密码,直接按Enter就行,然后生成id_rsa与id_rsa.pub文件,id_rsa.pub文件在c盘用户名下的.ssh文件夹。将id_rsa.pub里面的内容复制到github上面的(登陆你的github帐户。点击你的头像,然后 Settings -> 左栏点击 SSH and GPG keys -> 点击 New SSH key,然后你复制上面的公钥内容,粘贴进“Key”文本域内。 title域,自己随便起个名字。)
$ ssh -T git@github.com #验证是否配置成功
由于git支持https和git两种传输协议,使用ssh密钥好处就是:每次pull, push都不需要输入密码了。如下图:
2、在github.com新建仓库yourname/yourpro
3、本地新建文件夹test,初始化composer.json内容如下:
{
"name": "c2498168786/auto-test",
"description": "基于swagger-php的自动化测试",
"type": "library",
"license": "MIT",
"minimum-stability": "stable",
"authors": [
{
"name": "arrayhua",
"email": "2498168786@qq.com"
}
],
"autoload": {
"psr-4": {
"AutoTest\\": "./src"
}
},
"require": {
"php": ">=5.5.9",
"guzzlehttp/guzzle": "~6.2",
"swiftmailer/swiftmailer": "^5.4"
}
}
进行测试composer install,有东西安装则证明成功,在src文件夹新建测试文件
# HelloComposer.php
<?php
namespace AutoTest;
class HelloComposer
{
public static function greet()
{
echo "Hello, Composer!", PHP_EOL;
}
}
文件夹目录结构如下:
4.git add .&& git commit -am "init" && git pull orgin master && git push orgin master
5.创建releases,分支代表dev版本(除master外),tag代表stable版本 git tag 1.0 && git push origin master releases
常用git操作:
git status 查看状态
git add . 增加所有
git commit -a -m "注释" 本地提交
git pull 拉取远程版本
git push 提交本地版本到远程