记录问题:向空仓库,push代码。
问题:往空仓库push代码,方式1是ok的,方式2不行
方式1:
echo "# go_log" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:binwater/go_log.git
git push -u origin master
方式2:
git clone git@github.com:binwater/go_log.git
echo "# go_log" >> README.md
git add README.md
git commit -m "first commit"
git push -u origin master
如果master分支是被保护的话
push时报错如下:
! [remote rejected] master -> master (pre-receive hook declined)
原因:权限问题,Develop角色默认下没有远程访问master的权限
解决方案:
方案一:在项目的【Setting】中的【Protected branches】可以设置哪些分支是被保护的,默认情况下【master】分支是处于被保护状态下的,develop角色的人是无法提交到master分支的,在下面的【Developers can push】打上钩就可以了。
方案二:使用其他分支push 入