收集整理前端常用的命令,涉及 git、nginx、node、docker、linux 等
一、 git 篇
1、修改 .gitignore
文件后使其生效
git rm -r --cached .
git add .
git commit -m "update .gitignore"
2、查看 git 用户名信息 (设置用户信息后面跟用户信息
;查看/更改全局用户信息加 --global
)
git config user.name
git config user.email
3、查看 git 远端地址
git remote -v
4、更换 git 远端地址
git remote set-url origin https://xxxx.git
二、 Node 篇
1、清除 node_modules
缓存
# npm version < 7.0.0
$ npm cache clean -f
2、查看pm2
进程
pm2 ls -a
3、查看pm2
某个进程详情
pm2 show id
4、查看pm2
监控
pm2 monit
5、使用pm2
启动 xxx 的任务
pm2 start src/app.js --name xxx
三、Linux 篇
1、查看端口占用
netstat -tnlp | grep 80
2、查看进程详情
ps -aux | grep nginx
3、查看进程详情
ps -aux | grep nginx
3、查看服务状态详情
service xxx status
或
systemctl status xxx
四、Nginx 篇
1、nginx 检查语法是否正确
sudo nginx -t
2、nginx 重载配置文件以生效
sudo nginx -s reload
3、nginx 配置允许跨域
location / {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
if ($request_method = 'OPTIONS') {
return 204;
}
}