目录
一、前言
之前写的一些 Android 博文发现代码有不清楚或遗漏的,如:Android开发笔记之MVC、MVP、MVVM
然后做了一下补充,并把相关代码提交到github或gitee上去,并做了一些版本设置以方便查阅,写此博文稍微记录一下!
二、git提交代码、设置版本
1、项目代码提交到本地git
MacBook-Pro:mvc_mvp_mvvm luminal$ git initInitialized empty Git repository in /Users/。。。/02_Android高级_专题 /mvc_mvp_mvvm/code_AndroidStudio/mvc_mvp_mvvm/.git/MacBook-Pro:mvc_mvp_mvvm luminal$ git statusOn branch masterNo commits yetUntracked files:(use "git add <file>..." to include in what will be committed).gitignore.idea/LICENSEREADME.mdapp/build.gradlegradle.propertiesgradle/gradlewgradlew.batsettings.gradletestmode1_notused/nothing added to commit but untracked files present (use "git add" to track)MacBook-Pro:mvc_mvp_mvvm luminal$ git add .MacBook-Pro:mvc_mvp_mvvm luminal$ git statusOn branch masterNo commits yetChanges to be committed:(use "git rm --cached <file>..." to unstage)new file: .gitignorenew file: .idea/.namenew file: .idea/codeStyles/Project.xmlnew file: .idea/gradle.xmlnew file: .idea/misc.xmlnew file: .idea/runConfigurations.xmlnew file: .idea/vcs.xmlnew file: LICENSEnew file: README.md。。。。。。new file: testmode1_notused/src/main/res/values/colors.xmlnew file: testmode1_notused/src/main/res/values/strings.xmlnew file: testmode1_notused/src/main/res/values/styles.xmlnew file: testmode1_notused/src/test/java/com/yyh/testmode1_notused/ExampleUnitTest.javaMacBook-Pro:mvc_mvp_mvvm luminal$ git commit -m "不使用任何框架去实现需求"[master (root-commit) b11f9db] 不使用任何框架去实现需求70 files changed, 1458 insertions(+)create mode 100644 .gitignorecreate mode 100644 .idea/.namecreate mode 100644 .idea/codeStyles/Project.xmlcreate mode 100644 .idea/gradle.xml。。。。。。create mode 100644 testmode1_notused/src/main/res/mipmap-xxxhdpi/ic_launcher_round.pngcreate mode 100644 testmode1_notused/src/main/res/values/colors.xmlcreate mode 100644 testmode1_notused/src/main/res/values/strings.xmlcreate mode 100644 testmode1_notused/src/main/res/values/styles.xmlcreate mode 100644 testmode1_notused/src/test/java/com/yyh/testmode1_notused/ExampleUnitTest.javaMacBook-Pro:mvc_mvp_mvvm luminal$ git statusOn branch masternothing to commit, working tree clean2、项目代码提交到远程服务器gitee码云
MacBook-Pro:mvc_mvp_mvvm luminal$ git remote add origin https://gitee.com/。。。/mvc_mvp_mvvm.gitMacBook-Pro:mvc_mvp_mvvm luminal$ git push -u origin masterCounting objects: 108, done.Delta compression using up to 8 threads.Compressing objects: 100% (75/75), done.Writing objects: 100% (108/108), 127.83 KiB | 9.13 MiB/s, done.Total 108 (delta 9), reused 0 (delta 0)remote: Resolving deltas: 100% (9/9), done.remote: Powered by GITEE.COM [GNK-5.0]* [new branch] master -> masterBranch master set up to track remote branch master from origin.3、给提交的项目代码设置版本号
MacBook-Pro:mvc_mvp_mvvm luminal$ git tagMacBook-Pro:mvc_mvp_mvvm luminal$ git tag -a v1.0 -m "不使用任何框架去实现需求"MacBook-Pro:mvc_mvp_mvvm luminal$ git tagv1.0MacBook-Pro:mvc_mvp_mvvm luminal$ git push origin --tagsCounting objects: 1, done.Writing objects: 100% (1/1), 198 bytes | 198.00 KiB/s, done.Total 1 (delta 0), reused 0 (delta 0)remote: Powered by GITEE.COM [GNK-5.0]* [new tag] v1.0 -> v1.0MacBook-Pro:mvc_mvp_mvvm luminal$
4、git快速提交
用传统方式即命令行,把修改过后的代码快速上传到码云?
1、git add .
2、git commit -m "提交信息"
3、git push
如果不放心,在执行的前后加 git status 命令查看状态,如下:
$ git status$ git add .$ git status$ git commit -m "使用MVC模式去实现需求”$ git status$ git pushCounting objects: 38, done.Delta compression using up to 8 threads.Compressing objects: 100% (22/22), done.Writing objects: 100% (38/38), 5.70 KiB | 1.90 MiB/s, done.Total 38 (delta 1), reused 0 (delta 0)remote: Powered by GITEE.COM [GNK-5.0]b11f9db..c8944bf master -> master
5、删除某个版本
步骤1:gitee平台手动操作
假如我要删除如下版本v1.1
master--->管理,然后点击下图 删除 即可
步骤2:在 AS 控制台,执行命令行
MacBook-Pro:mvc_mvp_mvvm luminal$ git tag
v1.0
v1.1
MacBook-Pro:mvc_mvp_mvvm luminal$ git tag -d v1.1
Deleted tag 'v1.1' (was 76c9bac)
MacBook-Pro:mvc_mvp_mvvm luminal$ git tag
v1.0