新手将项目上传到github

再此之前查了好多人的资料都用着不对。老是出现各种问题。现在总算搞定 了。打算自己总结一下。方便自己以后使用学习

1.注册github账户

2.创建仓库。


做完上两步则创建完成。

3.安装Github shell程序 , 地址:http://windows.github.com/

4.打开git bash 界面,输入一下命令生成密匙来完成验证身份

ssh-keygen -C 'your@email.address' -t rsa
然后联系点击三次回车之后再windows当前用户目录下生成.ssh文件。如下图

把文件夹下的id_ras.pub文件内容全部复制, 然后打开github账户设置,如图


5.再次需注意最好设置一下自己的账号和密码

$ git config --global user.name "自己的账号"
$ git config --global user.email "自己的邮箱"

6.在git shell 下输入命令测试刚才的公钥是否认证正确

$ ssh -T git@github.com

正确结果会显示:

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://zddcyf@github.com':
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上看自己的项目了






  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
你好!作为一个新手,你可以按照以下步骤使用PyCharm将代码上传到GitHub: 1. 首先,你需要在GitHub上创建一个新的仓库。登录到GitHub,点击页面右上角的“+”按钮,选择“New repository”(新建仓库)。 2. 在创建仓库的页面上,为你的仓库选择一个名称,并添加一些描述。你可以选择将仓库设置为公共或私有,根据你的需求。 3. 完成创建后,你将被重定向到该仓库的页面。请复制该页面上的仓库URL,它将类似于“https://github.com/你的用户名/你的仓库名.git”。 4. 现在打开PyCharm,并打开你的项目。 5. 在PyCharm的顶部菜单中,选择“VCS”->“Import into Version Control”->“Share Project on GitHub”(版本控制->导入至版本控制->分享项目GitHub)。 6. 在弹出窗口中,粘贴刚刚复制的仓库URL,并点击“Share”(分享)。 7. PyCharm将提示你登录到GitHub。按照提示进行操作,完成登录后,你的项目将与GitHub仓库关联起来。 8. 现在,你可以在PyCharm中进行代码的修改和提交。点击底部工具栏上的“VCS”按钮,选择“Commit Changes”(提交更改),输入提交信息,并点击“Commit”(提交)。 9. 提交完成后,点击底部工具栏上的“VCS”按钮,选择“Git”->“Push”(推送)。这将把你的本地代码推送到GitHub仓库。 10. 推送完成后,你的代码就已经上传到GitHub了!你可以在GitHub仓库页面上查看代码的变化和提交历史。 希望这些步骤能帮助到你!如果你还有其他问题,请随时提问。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值