github上传code指南

来源:互联网 发布:大数据时代要求我们 编辑:程序博客网 时间:2024/06/12 18:19

今天把我的八卦头条app上传到了github。
https://github.com/vae260772/TopNews

做个小结,希望有所收获。
1、注册github账号。
2、下载git 工具。类似dos命令行
https://git-scm.com/downloads
3、在github上面创建项目。可以选择
勾选Initialize this repository with a README选项,这是自动创建REAMDE.md文件,省的你再创建。
这个东西就是一个帮助文档,没什么用,项目描述,介绍。。。

# TopNews1)Activity+fragment的 数据传递,fragment的setArguments/getArguments 2)viewpager+fragment的结合使用,包括fragment的setOffscreenPageLimit来设置缓存数据页面状态,fragment动态添加/删除。 添加可以选择支持的分类,这些分类是由服务器提供的,支持多选。 删除可以选择除当前界面的其他fragment,支持多选 3)actionbar的使用,其中涉及到sdk api的版本、是否兼容低版本的手机问题、Android.app.ActionBar和android.support.v7.widget.ActionBar2种包对应的 样式theme设置、bar中设置menu菜单点击问题等。 4)顶部切换的导航栏,使用第三方库。viewpager指示器:ViewPagerIndicator-library、 滚动的banner使用了cn.bingoogolapple.bgabanner.BGABanner ,其中banner中添加的网络图片加载使用了com.bumptech.glide.Glide图片处理框架。 5)fragment中主页使用recycleview显示。 下拉刷新的实现使用了第三方com.handmark.pulltorefresh.library.PullToRefreshBase, 但是由于第三方不支持recycleview显示数据,所以在第三方的代码基础上,扩展了刷新功能,支持recycleview的瀑布流显示(后来觉得瀑布流显示比较丑,又修改为gridview显示)。 6)新闻数据使用了 https://www.juhe.cn/docs/api/id/235 聚合数据新闻头条。 在首次启动应用时候,会自动从服务器获取数据,解析是服务器返回的json数据并将数据保存在android自带的sqlite数据库中,之后用户可以自己刷新加载最新新闻,如果断开网络可以加载已经缓存的数据。 7)RecyclerView.Adapter涉及到item重用,避免重绘导致内存泄漏。  item中涉及 com.nostra13.universalimageloader.core.ImageLoader 图片显示,以及长按点击收藏、在浏览器打开、分享功能。 8)向右侧滑弹出menu。SlidingMenu 。 9)验证码登录实现。 登录验证码这个使用的三方支持 www.mob.com 提供的sdk集成。 10)查看收藏以及搜索。在actionbar中实现和用户交互,界面响应。 11)边听音乐边浏览新闻。通过android sdk提供的mediaplayer结合service实现播放手机内存存储的音乐,包括音乐的暂停/播放,设置播放模式等功能,相当于内嵌了一个小的音乐播放器。 12)网络监听。使用了动态广播监听器来对网络是否可用进行实时响应并处理 android.net.conn.CONNECTIVITY_CHANGE,更新UI界面。

4、打开git shell。
ssh-keygen -C ‘973742475@qq.com’ -t rsa
在用户当前目录生成.ssh文件夹。我的C:\Users\lihui20.ssh
把文件夹下的id_rsa.pub文件内容全部复制。

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDF0wcA3rQH8HomNH2ifhB1LKwhNndGNwIzsHj0q2vkRydgW7c5rxuhUQx0zmyH62SHoL5XJLaxWlq+UVPJdQapaI682zBpYnTonwMU6AnrT3J09t8DHnP+pBeGxqCgTaqHkIXBUpE0Kd082I/FI7d9HxRKZfC1w8sw18CBURwTHRBmpLQboKTqR2PUOTFTaEDQirV9H+cqGAgpg3h5Q6rrbjw4mX86vZ3PrU0JaohmTerzOy8inuxibB+jbxuGZGIkhufLSzHRfqTbgSNu8njjFLCWwbHJuU98ahtuFb3nXwLTgPOKMWQ53uVCczXhgybnwkta+S9PjRlFTpQk6Bb7 973742475@qq.com

在github网址
https://github.com/settings/keys
里面填写生成的id_rsa key。

5、
在git shell里面输入
ssh -T git@github.com
结果。
$ ssh -T git@github.com
The authenticity of host ‘github.com (192.30.253.112)’ can’t be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘github.com,192.30.253.112’ (RSA) to the list of known hosts.
‘Hi vae260772! You’ve successfully authenticated, but GitHub does not provide shell access.
通过验证。

6、clone刚才新建的repository 到本地,输入命令:
在git shell
输入
$ git clone https://github.com/vae260772/TopNews.git
Cloning into ‘TopNews’…
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.

这个把git上面的仓库拉到本地,关联起来的!!!
本地会生成目录:
C:\Users\lihui20\TopNews

把提交的项目代码拷贝进去。
C:\Users\lihui20\TopNews\testhttp

7、之后就是常用的git 命令使用了
进入C:\Users\lihui20\TopNews\
目录下面
使用命令
add添加到本地:
$ git add testhttp/

commit提交到本地 :’topnews’是注释文字
$ git commit -m ‘topnews’

push到远程分支master
$ git push origin master

出现

lihui20@XIEWEN3-3210566 MINGW64 ~/TopNews (master)
$ git push origin master
Counting objects: 1104, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (850/850), done.
Writing objects: 100% (1104/1104), 8.25 MiB | 51.00 KiB/s, done.
Total 1104 (delta 305), reused 0 (delta 0)
remote: Resolving deltas: 100% (305/305), done.
To https://github.com/vae260772/TopNews.git
2169c35..4d8de8c master -> master

成功了,在网页刷新试试~~~~~~~~~

2017/6/8
topnews
https://github.com/vae260772/TopNews
今天想把github的代码 同步到我的androidstudio中,
这样修改之后,直接就能提交了。
1、下载 对应的本地目录,我的E:\github\TopNews ,下面执行
git clone https://github.com/vae260772/TopNews.git
把代码同步到本地

2、androidstudio 打开项目。

3、这样as下面修改,直接可以在git shell 下面 add 、commit、push了。

今天我提交出现了一个错误。

lihui20@XIEWEN3-3210566 MINGW64 /e/github/TopNews (master)$ git push origin masterTo https://github.com/vae260772/TopNews.git ! [rejected]        master -> master (non-fast-forward)error: failed to push some refs to 'https://github.com/vae260772/TopNews.git'hint: Updates were rejected because the tip of your current branch is behindhint: its remote counterpart. Integrate the remote changes (e.g.hint: 'git pull ...') before pushing again.hint: See the 'Note about fast-forwards' in 'git push --help' for details.

网上搜索了下,是因为远程repository和我本地的repository冲突导致的,而我在创建版本库后,在github的版本库页面点击了创建README.md文件的按钮创建了说明文档,但是却没有pull到本地。这样就产生了版本冲突的问题。

有如下几种解决方法:1.使用强制push的方法:$ git push -u origin master -f这样会使远程修改丢失,把被人的提交覆盖掉,这个意思。一般是不可取的,尤其是多人协作开发的时候。2.push前先将远程repository修改pull下来,更新本地最新同步,再提交$ git pull origin master$ git push -u origin master

参考:
https://www.douban.com/note/332510501/

原创粉丝点击