首页 技术 正文
技术 2022年11月14日
0 收藏 695 点赞 2,456 浏览 1594 个字

上传项目到gitHub

创建好后开始提交本地项目代码如图

选中VCS选中图中的按钮如图所示

然后再选中Src点中add按钮如图所示

然后点中commit Directory后
打开终端进行项目根目录下键入以下 命令:
git remote add origin git@github.com:codegeekgao/Test.git(这里我写的自己的github地址,这里可以改成你自己的github项目)
git push -u origin master //将本地仓库的东西提交到地址是origin的地址,master分支下

可能出现的报错异常

出现错误 error:src refspec master does not match any

引起该错误的原因是目录中没有文件,空目录是不能提交上去的.

解决办法:

在项目根目录下,创建README.md 文件即可$ touch README.md
$ git add README,md
$ git commit –m’first commit’
$ git push origin master

进一步可能再次出现Permission denied (publickey). fatal: Could not read from remote repository.

这是因为本地没有ssh的密钥,生成密钥,在GitHub上添加这个ssh密钥即可,操作步骤如下:

1.首先,如果你没有ssh key的话,在ternimal下输入命令:ssh-keygen -t rsa -C "youremail@example.com", youremail@example.com改为自己的邮箱即可,途中会让你输入密码啥的,不需要管,一路回车即可,会生成你的ssh key。(如果重新生成的话会覆盖之前的ssh key。)
2. 若是window操作系统,会在C盘的用户目录下创建一个ssh目录,同理ios系统也是在用户目录下有ssh目录。

用文本编辑器打开id_rsa.pub,复制里面的内容添加到github,如下图所示:

添加之后验证SSH的密钥

提示:Hi xxx! You've successfully authenticated, but GitHub does not provide shell  access.即为成功

提示出错信息:fatal: remote origin already exists. 解决办法如下:


然后再次输入git remote add origin git@github.com:codegeekgao/Test.git

git push -u origin master

然后会报以下错误:

! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git@github.com:qzmly100/repository-.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 integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

这是因为:

远程分支上存在本地分支中不存在的提交,往往是多人协作开发过程中遇到的问题,可以先fetch再merge,也就是pull,把远程分支上的提交合并到本地分支之后再push。

如果你确定远程分支上那些提交都不需要了,那么直接git push origin master -f,强行让本地分支覆盖远程分支.

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,492
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,495
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,133
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,297