hldbcisk 发表于 2021-5-31 02:35:55

月薪20k程序员必备技能:Pycharm连接github并上传代码

pycharm连接Github并上传代码
无知乃是罪恶,知识乃是我们借以飞向天堂的翅膀。——莎士比亚
Ignorance is the curse of God, knowledge the wing wherewith we fly to heaven. ——William Shakespeare
http://i1.go2yd.com/image.php?url=0UiD7yIxF7&zhiwu55.jpg
今天给大家分享的是,月薪20k程序员必备的一项技能。如何使用Pycharm连接到Github并上传代码。
一、Pycharm连接到Github
(1)检查git是否安装
打开Pycharm在上方菜单栏处,找到File----Setting
http://i1.go2yd.com/image.php?url=0UiD7yN3R3&zhiwu55.jpg
找到Version Control ----Git----Test
http://i1.go2yd.com/image.php?url=0UiD7yDCMG&zhiwu55.jpg
如果没有Git的话,建议首先安装Git软件,再回来进行配置
http://i1.go2yd.com/image.php?url=0UiD7yE07q&zhiwu55.jpg
Pycharm中默认可以加载git安装路径,如果测试不成功,可以手动添加git软件的安装路径。
http://i1.go2yd.com/image.php?url=0UiD7ySLGU&zhiwu55.jpg
测试成功后,下方会显示Git版本信息
http://i1.go2yd.com/image.php?url=0UiD7y7BOG&zhiwu55.jpg
(2)添加Github账户
依旧是Settings---Version Control---Github
http://i1.go2yd.com/image.php?url=0UiD7yr3ix&zhiwu55.jpg
http://i1.go2yd.com/image.php?url=0UiD7yYO96&zhiwu55.jpg
点击后,pycharm出现logging对话框,并自动打开浏览器
http://i1.go2yd.com/image.php?url=0UiD7ySQPq&zhiwu55.jpg
http://i1.go2yd.com/image.php?url=0UiD7yw0dl&zhiwu55.jpg
http://i1.go2yd.com/image.php?url=0UiD7yGCAF&zhiwu55.jpg
进入GIthub 账号密码认证界面,进行密码确认
http://i1.go2yd.com/image.php?url=0UiD7y3dMk&zhiwu55.jpg
点击认证成功后,便会跳转到认证成功的页面,关闭此页面即可。
http://i1.go2yd.com/image.php?url=0UiD7yggFU&zhiwu55.jpg
这时回到Pycharm,可以看到github账号已经被添加到右侧栏中
http://i1.go2yd.com/image.php?url=0UiD7yVlLm&zhiwu55.jpg
http://i1.go2yd.com/image.php?url=0UiD7yjR50&zhiwu55.jpg
二、Pycharm上传代码到Github
经过上述的一系列步骤后,我们已经使用Pycharm连接到GIthub。现在,我们来实现将本地代码上传到Github。
(1)建立远程GIthub仓库
在上方菜单栏中找到VCS----Share Project on Github
http://i1.go2yd.com/image.php?url=0UiD7ym3eu&zhiwu55.jpg
在弹出的对话框中,设置仓库名及描述, 并点击share。本文仓库名设置为"Pycharm_test",描述设置为"Pycharm testing!"。
http://i1.go2yd.com/image.php?url=0UiD7y52Rn&zhiwu55.jpg
http://i1.go2yd.com/image.php?url=0UiD7ycJ6l&zhiwu55.jpg
为便于测试,本次只选中提交一个文件(只选中ts.py文件)
http://i1.go2yd.com/image.php?url=0UiD7ypyGh&zhiwu55.jpg
http://i1.go2yd.com/image.php?url=0UiD7yG2m0&zhiwu55.jpg
完成后,右下角会弹出提示信息
http://i1.go2yd.com/image.php?url=0UiD7yVNHc&zhiwu55.jpg
可以看到,此时Pycharm_test仓库已经在Github上创建成功,但代码未push上传,我们打开github进行检验。
http://i1.go2yd.com/image.php?url=0UiD7yH2So&zhiwu55.jpg
http://i1.go2yd.com/image.php?url=0UiD7ydEHm&zhiwu55.jpg
(2)使用git上传代码到所建的远程仓库
在想要上传的代码文件处 右键---Git---Push
http://i1.go2yd.com/image.php?url=0UiD7yAvUY&zhiwu55.jpg
出现Push确认对话框,点击下方Push按钮,上传代码
http://i1.go2yd.com/image.php?url=0UiD7yEUVe&zhiwu55.jpg
此时下方菜单栏,便会显示push上传进度
http://i1.go2yd.com/image.php?url=0UiD7ySV4y&zhiwu55.jpg
有时可能会出现上传失败的情况,我们点击右下角的提示框,查看详细信息,来解决此问题
http://i1.go2yd.com/image.php?url=0UiD7yAIln&zhiwu55.jpg
http://i1.go2yd.com/image.php?url=0UiD7yiGfF&zhiwu55.jpg
这可能是由于网络波动,网速不太好,按照上述步骤重新push,可以看到再次push后,日志显示成功push上传。
http://i1.go2yd.com/image.php?url=0UiD7yIlzx&zhiwu55.jpg
此时,我们打开Github网页进行检验。可以看到,远程创建的Pycharm_test仓库中,已经成功上传了我们刚刚push的ts.py代码文件!
http://i1.go2yd.com/image.php?url=0UiD7y2RgB&zhiwu55.jpg

对此,你有什么看法呢?如果你在操作过程中遇到了什么问题,或有什么想法和建议,在留言区留下你的足迹吧,与大家一起交流,一起进步~
页: [1]
查看完整版本: 月薪20k程序员必备技能:Pycharm连接github并上传代码