再此之前查了好多人的资料都用着不对。老是出现各种问题。现在总算搞定 了。打算自己总结一下。方便自己以后使用学习
1.注册github账户
2.创建仓库。
做完上两步则创建完成。
3.安装Github shell程序 , 地址:http://windows.github.com/
4.打开git bash 界面,输入一下命令生成密匙来完成验证身份
ssh-keygen -C '[email protected]' -t rsa
然后联系点击三次回车之后再windows当前用户目录下生成.ssh文件。如下图
把文件夹下的id_ras.pub文件内容全部复制, 然后打开github账户设置,如图
5.再次需注意最好设置一下自己的账号和密码
$ git config --global user.name "自己的账号"
$ git config --global user.email "自己的邮箱"
6.在git shell 下输入命令测试刚才的公钥是否认证正确
$ ssh -T [email protected]
正确结果会显示:
Warning:Permanently added 'github.com,' (RSA) to the list of known hosts. Hi Flowerowl! You've successfully authenticated, but GitHub does not provide shell access.
Hi “此处你的账号”! You've successfully authenticated, but GitHub does not provide shell access.
warning 不用理会。
7.clone 刚才的新建的repository到本地,输入命令
输入此命令
$ git remote add origin https://github.com/cyf/Pager.git
此时会生成一下文件
8.在git shell 命令行下,输入命令
$ git init
$ git add .
$ git commit -m '提交了什么内容'
$ git remote add origin https://github.com/cyf/Pager.git
$ git push origin master
如果执行 git add .是出现
warning: LF will be replaced by CRLF in CircleViewPager/.idea/compiler.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CircleViewPager/.idea/encodings.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CircleViewPager/.idea/gradle.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CircleViewPager/.idea/misc.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CircleViewPager/.idea/modules.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CircleViewPager/.idea/runConfigurations.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CircleViewPager/.idea/vcs.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CircleViewPager/.svn/entries.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CircleViewPager/.svn/format.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CircleViewPager/.svn/pristine/24/241c61b5f7f3a822490f04ec41cd2b008fd9cc9e.svn-base.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CircleViewPager/.svn/pristine/2b/2b3e0b47e7e861defa270aa299f6187a6f9ff725.svn-base.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CircleViewPager/.svn/pristine/3d/3d21a3dbd9646e8dac71982f7f0efc488d4bd2ec.svn-base.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CircleViewPager/.svn/pristine/47/47a42ea21a483dd7306e90edb7cb1c71ab6f66f6.svn-base.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CircleViewPager/.svn/pristine/64/6409d6256df6b2f9e2142183b4c6408823a10f6a.svn-base.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CircleViewPager/.svn/pristine/8d/8d525942e34b1d002521094f14f3a4ed58f8fcf2.svn-base.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CircleViewPager/.svn/pristine/ac/ac2b1dcc599109e881ca2346d8b37617dbb93381.svn-base.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CircleViewPager/.svn/pristine/b3/b3b4495e27f23fc5db8021086138d04c7ec34aef.svn-base.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CircleViewPager/.svn/pristine/cb/cb6d4fb786a746463f50e2c3651ca619b642d4f1.svn-base.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CircleViewPager/.svn/pristine/ff/ffaf4ced158f4d99995aeac7db7aedcbd95f577d.svn-base.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CircleViewPager/app/src/main/java/zdd/circleviewpager/circleindicator/CircleIndicator.java.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CircleViewPager/app/src/main/java/zdd/circleviewpager/circleindicator/CustomDurationScroller.java.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CircleViewPager/gradle/wrapper/gradle-wrapper.properties.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CircleViewPager/gradlew.
The file will have its original line endings in your working directory.
这个错误,则执行下列代码 ,删除刚刚生成的.git文件
$ rm - rf .git
$ git config --global core.autocrlf false
执行完之后则重新执行
$ git init
$ git add .
$ git remote add origin https://github.com/cyf/Pager.git
如果执行
$ git remote add origin https://github.com/cyf/Pager.git
出现错误:
fatal: remote origin already exists
则执行一下语句:
$ git remote rm origin
再往后执行
$ git remote add origin https://github.com/cyf/Pager.git
在执行git push origin master时,报错:
error:failed to push som refs to.......
则执行以下语句:
$ git pull origin master
先把远程服务器github上面的文件拉先来,再push 上去。
$ git push origin master
Username for 'https://github.com':
Password for 'https://[email protected]':
Counting objects: 195, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (172/172), done.
Writing objects: 100% (195/195), 867.55 KiB | 0 bytes/s, done.
Total 195 (delta 15), reused 0 (delta 0)
To https://github.com/cyf/Pager.git
3d63da9..38260c5 master -> master
出现此则说明上传成功了
然后你就可以去github上看自己的项目了