用pycharm上传代码到GitHub

1、点击工具栏VCS没有git和commit选项,点击VCS ->Enable Version Control Integration…

python菜单栏为什么没有VCS_python


在跳出的弹框内选择Git,点击ok

python菜单栏为什么没有VCS_python_02


设置好之后的效果如下图

python菜单栏为什么没有VCS_python菜单栏为什么没有VCS_03


2、设置GitHub用户

File->settings->选择GitHub选项,点击添加用户(从2021年8月14日开始,GitHub不再接受密码验证,要使用token进行验证)

python菜单栏为什么没有VCS_git_04


添加成功后,点击OK

python菜单栏为什么没有VCS_github_05


token验证步骤如下:

(1)GitHub token获取

setting-> Developer setting-> personal access tokens-> Generate new token ->填入命名->Select scopes全选 -> Generate token

python菜单栏为什么没有VCS_github_06


python菜单栏为什么没有VCS_git_07


python菜单栏为什么没有VCS_git_08


python菜单栏为什么没有VCS_github_09


自己任意命名,只要可以区分就可以:

python菜单栏为什么没有VCS_python菜单栏为什么没有VCS_10


python菜单栏为什么没有VCS_python_11

python菜单栏为什么没有VCS_git_12

python菜单栏为什么没有VCS_python_13


python菜单栏为什么没有VCS_python菜单栏为什么没有VCS_14


python菜单栏为什么没有VCS_git_15

3、安装Git.exe,安装成功后设置安装git.exe的路径,点击Test

python菜单栏为什么没有VCS_python菜单栏为什么没有VCS_16


4、新建此项目上传的仓库

python菜单栏为什么没有VCS_git_17


点击后跳出弹窗,填入信息后点击Share

python菜单栏为什么没有VCS_python菜单栏为什么没有VCS_18


新建成功后右下角提示

python菜单栏为什么没有VCS_github_19

5、上传代码

点击Commit,先将代码同步到本地,再从本地同步到GitHub

python菜单栏为什么没有VCS_python菜单栏为什么没有VCS_20


python菜单栏为什么没有VCS_github_21


点击VCS->Git->push,将代码同步到GitHub

python菜单栏为什么没有VCS_python_22


提示成功后可以登录GitHub->Your repositories进行查看上传的项目

python菜单栏为什么没有VCS_github_23


6、push异常情况处理

①配置好首次push时报错

python菜单栏为什么没有VCS_python菜单栏为什么没有VCS_24


CMD命令进入,刷新DNS解析缓存

– git config --global http.ssIVerify “false”

– ipconfig /flushdns

python菜单栏为什么没有VCS_github_25


② 再次push报错

python菜单栏为什么没有VCS_python菜单栏为什么没有VCS_26


到项目目录下,右键选择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工程路径

python菜单栏为什么没有VCS_git_27


在pycharm再次push,成功