总结 本章命令概览
最后更新于:2022-04-02 01:41:54
[TOC]
## 日常命令
### 启动 Homestead 并登录
~~~bash
> cd E:/Homestead && vagrant up && vagrant ssh
$ cd ~/Code/Laravel
~~~
### 退出与关闭虚拟机
~~~bash
$ exit
> vagrant halt
~~~
### 日常更新至线上
~~~bash
$ git add -A
$ git commit -m "更新"
$ git push
~~~
#### 强制撤销暂存区更改
~~~bash
$ git checkout -f
~~~
#### 建立分支
~~~bash
$ git checkout master
$ git checkout -b filling-layout-style
~~~
## 初始配置命令
### 添加虚拟盒子
~~~bash
> cd E:/lt-homestead-3-0-0-2017082400
> vagrant box add metadata.json
~~~
### 下载管理脚本并初始化
~~~bash
> cd E:/
> git clone https://git.coding.net/summerblue/homestead.git Homestead
> cd Homestead
> bash init.sh
~~~
### 打开文件管理器
~~~bash
> explorer .
~~~
### 编辑 Homestead.yaml 配置文件
样本如下
~~~
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
- ~/.ssh/id_rsa.pub
folders:
- map: E:/Homestead/code
to: /home/vagrant/Code
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
databases:
- homestead
# blackfire:
# - id: foo
# token: bar
# client-id: foo
# client-token: bar
# ports:
# - send: 50000
# to: 5000
# - send: 7777
# to: 777
# protocol: udp
~~~
### SSH key 检测与生成
~~~bash
> ls -al ~/.ssh
> ssh-keygen -t rsa -C "your_email@example.com"
~~~
### 生成代码摆放文件夹
~~~bash
> cd E:/Homestead
> mkdir code
~~~
### 修改 hosts
文件位于`C:\Windows\System32\Drivers\etc\hosts`
~~~text
192.168.10.10 homestead.app
~~~
### 启动 Homestead 并登录
~~~bash
> cd E:/Homestead && vagrant up
> vagrant ssh
~~~
### 创建 Laravel 应用
~~~bash
$ cd ~/Code
$ composer create-project laravel/laravel Laravel --prefer-dist "5.5.*"
~~~
### 第一次运行虚拟机,进行 Git 配置
~~~bash
$ git config --global user.name "Your Name"
$ git config --global user.email your_email@example.com
$ git config --global push.default simple
~~~
### 初始化一个本地 Git 项目
~~~bash
$ cd ~/Code/Laravel
$ git init
~~~
### 项目文件保存到暂存区
~~~bash
$ git add -A
~~~
### 暂存区文件列表
~~~bash
$ git status
~~~
### 提交到 Git
~~~bash
$ git commit -m "Initial commit"
~~~
### 线上代码仓库配置
#### 将 `SSH Key` 添加到 `ssh-agent` 中
~~~bash
$ eval `ssh-agent -s`
$ ssh-add ~/.ssh/id_rsa
~~~
#### 打印并复制,再黏贴到线上 SSH 令牌管理页面
~~~bash
> cat ~/.ssh/id_rsa.pub
~~~
#### 将代码上传到 Gitee 上完成托管
~~~bash
$ git remote add origin git@gitee.com:your_name/laravel.git
$ git push -u origin master
~~~
';