以前提交github仓库的时候,用的都是github desktop工具。使用久了也觉得挺好,但是每次都要打开github destop工具也确实没有直接在AS中来的方便。今天我们将在AS中配置git,关联到github。
-
下载git版本,按默认的方式进行安装就可以
https://git-scm.com/downloads -
安装完后打开git,配置相关参数
1,git config --global user.email "you@example.com"
2,git config --global user.name "Your Name"
3,退出Git,进入到AS,然后打开File -> Settings -> Version Control -> Git, 接着在Path to Git executable里把安装好的git.exe路径复现到这里,并且点击右边的Test,如果路径正确则会提示成功。
![](https://img.haomeiwen.com/i12467646/220f98dd84a686d0.png)
![](https://img.haomeiwen.com/i12467646/1be69e1666234647.png)
4,点击VCS -> VCS Operations popup...调出如下选项,选择Git后点击ok
![](https://img.haomeiwen.com/i12467646/aac460f1fb2ed4f0.png)
5, 如果github上没有相关工程,需要新建仓库时,执行VCS -> Import into Version Control -> Share Project on GitHub然后就可以输入账号和密码。
![](https://img.haomeiwen.com/i12467646/c8e43673513ebb94.png)
![](https://img.haomeiwen.com/i12467646/79c34600139f247f.png)
6,如果本地已经在gitHub上有了仓库,需要提交代码,那么右键工程文件到Git里的Commit Directory就可以提交,如果想要更新代码也可以选择同级菜单下的repository选项。
注:如果当前项目有新增的文件(红色显示),需要右键选择Add关联到git中。
![](https://img.haomeiwen.com/i12467646/8f945f3221738b05.png)
网友评论