最近在写一个简单的androi项目,不过由于人员管理上松散,所以决定把代码提交至github,提前感受一下一直很火的github
苦逼历程:
1、本来想偷懒,看看有没有类似subversion,简单操作的团队开源工具,不过之前是在javaweb方向上使用,在移动开发上当然用适合的工具了,于是舍弃之
2、再一想,有莫有eclipse的插件,集成上传,下载github上的源码呢?找到了http://www.iteye.com/topic/1122423(使用github管理Eclipse分布式项目开发)
,但是说的不是很详细,因为我的eclipse是最新google公司的版本,安上插件会报错,而且启动界面也会有变化,鼓捣了2个小时,但是仍然没有头绪,又舍弃之
3、最后,我安定思痛,想想我想要的流程是什么?
- 上传本地代码->github网站
- 团队其他人从上面拷贝下来
- 改完之后再提交上去
下面的代码是记录记录而已,有兴趣的可以看一下,时间比较仓促,还望多多够沟通,一起在github上关注、学习大牛们!
Welcome to Git (version 1.8.3-preview20130601)
Run 'git help git' to display the help index.
Run 'git help <command>' to display help for specific commands.
Administrator@VAIO-11061700 /d/GitHub/RescueApp
$ git config --global user.name "jptiancai"
Administrator@VAIO-11061700 /d/GitHub/RescueApp
$ git config --global user.email mail_jzy@163.com
Administrator@VAIO-11061700 /d/GitHub/RescueApp
$ ssh-keygen -C 'mail_jzy@163.com' -t rsa
Administrator@VAIO-11061700 /d/GitHub/RescueApp
$ ssh-keygen -C 'mail_jzy@163.com' -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Documents and Settings/Administrator/.ss
h/id_rsa):
/c/Documents and Settings/Administrator/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Documents and Settings/Administrator/.s
sh/id_rsa.
Your public key has been saved in /c/Documents and Settings/Administrator/.ssh/i
d_rsa.pub.
The key fingerprint is:
9f:be:0c:2e:de:a5:5f:2b:86:3e:73:1d:33:71:60:ab mail_jzy@163.com
Administrator@VAIO-11061700 /d/GitHub/RescueApp
$ git init
Initialized empty Git repository in D:/GitHub/RescueApp/.git/
Administrator@VAIO-11061700 /d/GitHub/RescueApp (master)
$ git add .
warning: LF will be replaced by CRLF in AndroidManifest.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in gen/com/yonvoo/main/BuildConfig.java.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in proguard-project.txt.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in project.properties.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in res/values-v11/styles.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in res/values-v14/styles.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in res/values/strings.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in res/values/styles.xml.
The file will have its original line endings in your working directory.
Administrator@VAIO-11061700 /d/GitHub/RescueApp (master)
$ git remote add origin git@github.com:jptiancai/RescueApp.git
Administrator@VAIO-11061700 /d/GitHub/RescueApp (master)
$ git push origin master
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Administrator@VAIO-11061700 /d/GitHub/RescueApp (master)
$ git push origin master
The authenticity of host 'github.com (204.232.175.90)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added 'github.com,204.232.175.90' (RSA) to the list of know
n hosts.
error: src refspec master does not match any.
error: failed to push some refs to 'git@github.com:jptiancai/RescueApp.git'
Administrator@VAIO-11061700 /d/GitHub/RescueApp (master)
$ git push origin master
error: src refspec master does not match any.
error: failed to push some refs to 'git@github.com:jptiancai/RescueApp.git'
Administrator@VAIO-11061700 /d/GitHub/RescueApp (master)
$ git commit -m 'initial commit'
[master (root-commit) 926da3f] initial commit
warning: LF will be replaced by CRLF in AndroidManifest.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in gen/com/yonvoo/main/BuildConfig.java.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in proguard-project.txt.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in project.properties.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in res/values-v11/styles.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in res/values-v14/styles.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in res/values/strings.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in res/values/styles.xml.
The file will have its original line endings in your working directory.
74 files changed, 1548 insertions(+)
create mode 100644 .gitattributes
create mode 100644 .gitignore
create mode 100644 AndroidManifest.xml
create mode 100644 gen/com/yonvoo/main/BuildConfig.java
create mode 100644 gen/com/yonvoo/main/R.java
create mode 100644 ic_launcher-web.png
create mode 100644 libs/android-support-v4.jar
create mode 100644 proguard-project.txt
create mode 100644 project.properties
create mode 100644 res/drawable-hdpi/app_logo.png
create mode 100644 res/drawable-hdpi/bg.png
create mode 100644 res/drawable-hdpi/butten_pressed.png
create mode 100644 res/drawable-hdpi/dark_dot.png
create mode 100644 res/drawable-hdpi/guide_350_01.jpg
create mode 100644 res/drawable-hdpi/guide_350_02.jpg
create mode 100644 res/drawable-hdpi/guide_350_03.jpg
create mode 100644 res/drawable-hdpi/guide_350_04.jpg
create mode 100644 res/drawable-hdpi/ic_launcher.png
create mode 100644 res/drawable-hdpi/item_bg.png
create mode 100644 res/drawable-hdpi/photo8.png
create mode 100644 res/drawable-hdpi/richangyiwai.png
create mode 100644 res/drawable-hdpi/settings.png
create mode 100644 res/drawable-hdpi/welcome.png
create mode 100644 res/drawable-hdpi/welcome_android.jpg
create mode 100644 res/drawable-hdpi/white_dot.png
create mode 100644 res/drawable-hdpi/yundongzijiu.png
create mode 100644 res/drawable-hdpi/ziranzaihai.png
create mode 100644 res/drawable-ldpi/butten_pressed.png
create mode 100644 res/drawable-ldpi/butten_unpress.png
create mode 100644 res/drawable-ldpi/dark_dot.png
create mode 100644 res/drawable-ldpi/guide_350_01.jpg
create mode 100644 res/drawable-ldpi/guide_350_02.jpg
create mode 100644 res/drawable-ldpi/guide_350_03.jpg
create mode 100644 res/drawable-ldpi/guide_350_04.jpg
create mode 100644 res/drawable-ldpi/ic_launcher.png
create mode 100644 res/drawable-ldpi/logo.png
create mode 100644 res/drawable-ldpi/welcome_android.jpg
create mode 100644 res/drawable-ldpi/white_dot.png
create mode 100644 res/drawable-mdpi/ic_launcher.png
create mode 100644 res/drawable-xhdpi/ic_launcher.png
create mode 100644 res/drawable/dot.xml
create mode 100644 res/drawable/whats_new_start_btn.xml
create mode 100644 res/layout/detail.xml
create mode 100644 res/layout/griditem.xml
create mode 100644 res/layout/guide.xml
create mode 100644 res/layout/listview_item.xml
create mode 100644 res/layout/main.xml
create mode 100644 res/layout/splash.xml
create mode 100644 res/layout/test.xml
create mode 100644 res/layout/what_new_four.xml
create mode 100644 res/layout/what_new_one.xml
create mode 100644 res/layout/what_new_three.xml
create mode 100644 res/layout/what_new_two.xml
create mode 100644 res/menu/activity_main.xml
create mode 100644 res/values-v11/styles.xml
create mode 100644 res/values-v14/styles.xml
create mode 100644 res/values/strings.xml
create mode 100644 res/values/styles.xml
create mode 100644 src/com/yonvoo/activity/DetailActivity.java
create mode 100644 src/com/yonvoo/activity/GuideActivity.java
create mode 100644 src/com/yonvoo/activity/MainActivity.java
create mode 100644 src/com/yonvoo/activity/SecCategoryActivity.java
create mode 100644 src/com/yonvoo/activity/SplashActivity.java
create mode 100644 src/com/yonvoo/adapter/GridViewAdapter.java
create mode 100644 src/com/yonvoo/adapter/ListViewAdapter.java
create mode 100644 src/com/yonvoo/adapter/ViewPagerAdapter.java
create mode 100644 src/com/yonvoo/domain/Category.java
create mode 100644 src/com/yonvoo/domain/Detail.java
create mode 100644 src/com/yonvoo/domain/SecCategory.java
create mode 100644 src/com/yonvoo/service/CategoryService.java
create mode 100644 src/com/yonvoo/service/DBHelper.java
create mode 100644 src/com/yonvoo/service/DetailService.java
create mode 100644 src/com/yonvoo/service/SecCategoryService.java
create mode 100644 src/com/yonvoo/test/DBTest.java
Administrator@VAIO-11061700 /d/GitHub/RescueApp (master)
$ git push origin master
To git@github.com:jptiancai/RescueApp.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git@github.com:jptiancai/RescueApp.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first merge the remote changes (e.g.,
hint: 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Administrator@VAIO-11061700 /d/GitHub/RescueApp (master)
$ git push -f
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
Counting objects: 92, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (81/81), done.
Writing objects: 100% (92/92), 2.20 MiB | 966.00 KiB/s, done.
Total 92 (delta 12), reused 0 (delta 0)
To git@github.com:jptiancai/RescueApp.git
+ be58463...926da3f master -> master (forced update)
Administrator@VAIO-11061700 /d/GitHub/RescueApp (master)
$
---------------------------------------------------2014年5月6日更新--------------------------------------------------
时隔多日,再次用到git这个神级的版本管理工具的时候,上面的代码依然有用,在这里稍微总结一下,方便以后查看:
创建个人项目到github上或者fork别人的项目
- 配置用户名、密码、私钥--->和github取得连接,如需要设置代理上网,请看这篇:在公司的局域网使用git或github 设置代理[1]
- 添加本地文件到github代码库中---> inti,add,remote add, commit,push,遇到master整合到master的时候,可以用 -f,强制merge
- git clone github地址,可参照下图直接复制粘贴。
- GitHub Guides[2]:目前教学文章较少,仅仅9篇,但是篇篇都很经典,从HelloWorld开始看,你一定会有收获。
- Git官网[3]:网站十分友好,提供了在线TryGit学习方式,文档,视频,软件,一应俱全。
- Git cheatsheet[4]:里面有大部分的命令,很实用!
提交你自己的代码,参考Pushing to a remote[5]
fork你喜欢的库
--------------
git branch new_branch git checkout new_branch 一系列操作(git add......) git push origin new_branch
----------------之后刷新官网会有所显示,提交上去,等待使用者审核通过
提交自己的代码,同步最新的代码,参考[6],[7]
merge到自己项目的master上,提交后就看原作者的审核了 git checkout master--->以master的身份运行 git merge new_branch git diff new_branch master git status
--------------------------------------------------2014年5月6日更新--------------------------------------------------
- 如果你想发表博客到github上,这个网站是个不错的选择:GitHub Pages[8]
--------------------------------------------------2014年12月26日更新--------------------------------------------------
情景:已经从原始项目(orgin)在页面上fork一个自己的项目主页(master),本地上也有一个工作版本(local,虽然在控制台上看到的是master,但是应该这样理解).最近看到origin项目更新的好多东西,首先是更新
- git fetch xx(origin项目的git地址,这个可以在页面copy):bash返回信息 * branch HEAD -> FETCH_HEAD
- git merge HEAD FETCH_HEAD:按照提示,本地仓库(local)和原始项目(origin)同步信息
- git push:本地项目(local)提交到自己的项目主页(master).
参考文献
[2]. GitHub Guides[3]. Git官网[4]. Git cheatsheet[5] Pushing to a remote[6]. 花20分钟写的-大白话讲解如何给github上项目贡献代码[8]. GitHub Pages