android studio git使用上传新项目、更新、提交

来源:互联网 发布:php 存储json 编辑:程序博客网 时间:2024/06/05 17:15

新项目创建上传

先下好GIT
到项目文件夹下
右键→Git Bash


$ git init//初始化 
$ touch README
$ git add README//更新README文件
$ git commit -m 'first commit'//提交更新,并注释信息“first commit” 
$ git remote add origin 远程url//连接远程github项目  
这里我用的是码云Git@OSC(创建android项目仓库,然后复制url)


$ touch gitignore //创建忽略文件
并在里面填写网上的忽略模板(app文件夹下面也有,同样填好)


打开studio,VCS→Enable Control Integration→选择Git
选中项目→VCS→Git→Add
然后VCS→Commit Changes 点击commit(这时忽略文件会生效)


最后到项目文件夹下
右键→Git Bash
$ git push -u origin master

PS:这里的origin是默认的用户名可以通过git config --global user.name ""进行修改


克隆项目

File→New→Project from Version Control→Git
刚clone下来的时候,android模式下是没有东西的,这时候需要重构

File→Project Stucture→选择SDK版本


提交代码
VCS→update project
VCS→commit Changes
到项目文件夹下
右键→Git Bash
$ git pull origin master //更新
$ git push -u origin master //提交
1 0