将项目发布到Git@OSC

最后更新于:2022-04-01 03:32:23

Git 是我们常用的代码版本管理工具。 我们协作开发使用的是 OSChina 提供的 git 免费服务。 这篇文章将要讲解,如何使用WebStorm 将项目发布到 Git@OSC 我已经在OSC建立了一个空白的git项目` 项目创建后进入管理清空项目`。 https://git.oschina.net/caomenglong/ExpressDemo.git ![2015-08-08/55c5bb692a4f3](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-08-08_55c5bb692a4f3.png) 我将带领大家把项目代码利用WebStorm 发布进去。 * * * * * #### **本地Git代码仓库建立** 首先需要启用项目的版本管理功能 点击VCS 启用版本控制 ![2015-08-08/55c5b33c7aee2](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-08-08_55c5b33c7aee2.png) ![2015-08-08/55c5b38868d14](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-08-08_55c5b38868d14.png) IDE底部显示本地Git代码仓库建立完毕 ![2015-08-08/55c5b39e53b3b](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-08-08_55c5b39e53b3b.png) 这时就代表这个项目已经可以使用Git版本控制了。我们再点击VCS就可以看见Git菜单了。 ![2015-08-08/55c5b44639879](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-08-08_55c5b44639879.png) 首先我们先右击项目 选择`Git->add`,将项目中的文件 加入到git add 中等待本地提交。 ![2015-08-08/55c5b493ebb92](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-08-08_55c5b493ebb92.png) add 后文件都会由`橙色`变成 `绿色` ![2015-08-08/55c5b4ba7bd02](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-08-08_55c5b4ba7bd02.png) 下一步本地提交代码,右击项目,选择 `Git->Commit` ![2015-08-08/55c5b531ea0fc](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-08-08_55c5b531ea0fc.png) ![2015-08-08/55c5b6858e6cc](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-08-08_55c5b6858e6cc.png) 点击Commit是会出现 `Performing Code Analysis `提示,有时候会很慢,这个功能是它对代码进行分析,查找错误,并提醒你是否修改。 每次提交前都要查询一次,很麻烦,可以关闭该功能。 ![2015-08-08/55c5b7c77c972](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-08-08_55c5b7c77c972.png) 取消`Performing Code Analysis `复选框即可。 ![2015-08-08/55c5b82627851](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-08-08_55c5b82627851.png) ![2015-08-08/55c5b833a479f](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-08-08_55c5b833a479f.png) ![2015-08-08/55c5b84906318](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-08-08_55c5b84906318.png) 这时本地提交成功,可以看见颜色 从 `绿色` 变成 了 `黑色` ![2015-08-08/55c5b85c912a0](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-08-08_55c5b85c912a0.png) * * * * * ### **将代码push到远程 git 仓库** 代码Pull 远程前,必须先要进行本地Commit完毕。 ![2015-08-08/55c5b95a961cb](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-08-08_55c5b95a961cb.png) 右击项目 `Git-> Repository -> Push` ![2015-08-08/55c5b9d064fc6](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-08-08_55c5b9d064fc6.png) 点击` Define remote` 设置一个远程Git 仓库 ![2015-08-08/55c5ba0bebb91](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-08-08_55c5ba0bebb91.png) URL 输入 之前准备的 Git https://git.oschina.net/caomenglong/ExpressDemo.git ![2015-08-08/55c5ba7c3a018](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-08-08_55c5ba7c3a018.png) 输入 Git@OSC 账号密码。 ![2015-08-08/55c5bab96416a](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-08-08_55c5bab96416a.png) 再输入二次密码 ![2015-08-08/55c5baddb7786](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-08-08_55c5baddb7786.png) 远程Git设置成功,点击Push 就可以了! ![2015-08-08/55c5bb4c717e3](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-08-08_55c5bb4c717e3.png) ![2015-08-08/55c5bb9e6d065](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-08-08_55c5bb9e6d065.png) `Push successful ` 代码Push成功! ![2015-08-08/55c5bbe30e2aa](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-08-08_55c5bbe30e2aa.png) 到这里我们就完成了 项目代码发布到Git中了! 感谢观看
';