【PyCharm】配置 Git 教程
之前给大家介绍了 Git 安装及使用指南,今天再给大家介绍一下在 PyCharm 中使用 Git。
1
打开 File -> Settings -> Version Control -> Git
,在 Path to Git executable
处选择 git 的安装位置。

配置完成之后,点击【Test】按钮,如果成功,则会显示 Git 版本信息,如下图:

2
点击 VCS -> Checkout from Version Control -> Git

输入 GitHub 仓库的地址和本地目录,需要注意的是:这个目录必须是空的,不能有任何文件。PyCharm 新建项目的时候,会自动创建 .idea
文件夹,这个也不能有,必须删掉。

点击【Log in to GitHub】,输入用户名密码登录:

登录成功以后,点击【Clone】。Git 克隆完成。
3
在项目中新建文件,弹出提示框:是否将文件添加到 Git。

这里可以勾上 Remember, don't ask again
在点击【Yes】,这样就不会每次新建文件都弹出来了。
打开 右键 -> Git -> Commit File...
,输入 Commit Message
后点击下方【Commit】按钮。注意,提交日志是必须填的,否则不给提交的。


已经提交的文件文件名显示是 白色,未提交的文件文件名显示是 绿色,如下图:

打开 右键 -> Git -> Repository -> Push
,点击【Push】按钮,将代码提交到 GitHub。
