1.场景
进公司会分发gitlab账号,要求你克隆代码,并在项目分支dev上开发代码(推拉代码)
而git clone只能clone远程库的master分支,无法clone所有分支
2.解决办法如下:
1. 新建一个文件夹(注意看看是不是在master分支上,不行就换到d盘、f盘之类的)
2. 点上去,右键git bash here
3. git clone http://myrepo.xxx.com/project/.git ,这样在git_work目录下得到一个project子目录
4. cd project(会生成一个子文件夹,点进去再Git bash here )
5. git branch -a,列出所有分支名称如下:
remotes/origin/dev
remotes/origin/release
6. git checkout -b dev origin/dev,作用是checkout远程的dev分支,在本地起名为dev分支,并切换到本地的dev分支(就是将远程的分支搞到本地并建立关联,之后就可以进行推送了,重点理解origin可以理解为一个网址)
7. git checkout -b release origin/release,作用参见上一步解释
8. git checkout dev,切换回dev分支,并开始开发。
9.之后就可以git add . git commit -m '初始化' git push了
3.关于windows环境下npm报错
Error: pngquant failed to build, make sure that libpng-dev is installed error code ELIFECYCLE error errno 1 error pngquant-bin@4.0.0 postinstall: `node lib/install.js` error Exit status 1 error Failed at the pngquant-bin@4.0.0 postinstall script. error This is probably not a problem with npm. There is likely additional logging output above. verbose exit [ 1, true ]