最近接触到微信小程序,习惯了做版本控制,尝试用开发者工具配置git做版本控制,但是多次查资料无果,只能手动做代码提交和版本控制,操作记录如下。windows10 系统。
1.初始化本地仓库
win+r 键入cmd进入命令行界面,windows10 支持win+r键入powershell进入powershell操作
进入小程序文件目录:

(前提是安装git)使用git init 命令初始化本地仓库,原来很多项目文件都可以这样来做版本控制。
创建本地仓库后,可以在项目文件目录中看到一个.git的隐藏文件。
git相关命令学习:git常用命令清单
2.提交代码到本地仓库
在项目文件目录中操作以下命令:
git add 文件名 添加要提交到本地仓库的文件名或文件夹名
git commit -m "备注信息" 将已添加的文件或者文件夹提交到本地仓库



可以使用命令 git branch 查看本地仓库的分支,会显示一个绿色的标有*的master分支。
3.同步到远程仓库
在项目文件目录中操作以下命令:
git remote add origin 远程仓库地址 添加远程仓库地址
git push origin master 提交本地仓库当前分支代码(默认是master)到远程仓库的master分支
git branch -a 查看本地和远程仓库的所有分支



4.代码克隆、拉取、提交操作
代码克隆、拉取、提交的操作命令主要是
git clone origin 克隆
git pull origin master 拉取
git push origin master 提交
关于分支切换,新建分支等参考:git常用命令清单
微信开发者工具支持代码仓库,用户点击即可进入腾讯提供的代码仓库,和gitlab、github类似,看个人喜好吧。

网友评论