用pycharm上传代码到GitHub
1、点击工具栏VCS没有git和commit选项,点击VCS ->Enable Version Control Integration…
在跳出的弹框内选择Git,点击ok
设置好之后的效果如下图
2、设置GitHub用户
File->settings->选择GitHub选项,点击添加用户(从2021年8月14日开始,GitHub不再接受密码验证,要使用token进行验证)
添加成功后,点击OK
token验证步骤如下:
(1)GitHub token获取
setting-> Developer setting-> personal access tokens-> Generate new token ->填入命名->Select scopes全选 -> Generate token
自己任意命名,只要可以区分就可以:
3、安装Git.exe,安装成功后设置安装git.exe的路径,点击Test
4、新建此项目上传的仓库
点击后跳出弹窗,填入信息后点击Share
新建成功后右下角提示
5、上传代码
点击Commit,先将代码同步到本地,再从本地同步到GitHub
点击VCS->Git->push,将代码同步到GitHub
提示成功后可以登录GitHub->Your repositories进行查看上传的项目
6、push异常情况处理
①配置好首次push时报错
CMD命令进入,刷新DNS解析缓存
– git config --global http.ssIVerify “false”
– ipconfig /flushdns
② 再次push报错
到项目目录下,右键选择Git Bash Here
执行命令:git remote set-url origin https://github.com/jinzhe-mu/muwj_python_hm_mxdx.git
其中 https://github.com/jinzhe-mu/muwj_python_hm_mxdx.git 是github工程路径
在pycharm再次push,成功