笔记:Git创建远程仓库并提交Github、Gitee

1、弹出git 操作台
项目内的根目录 右键 git bash here
2、输入用户名(随意设置都行)
输入 git config --global user.name "wlj"
3、 输入邮箱
输入 git config --global user.email "870182492@qq.com"
4、初始化git
输入 git init
image.png

5、把项目的所有文件添加到git空间
输入 git add . 如果想添加某个特定的文件,只需把.换成特定的文件名即可
image.png

6、提交本地git仓库,输入提交描述信息
输入 git commit -m "描述你提交哪些内容,如:第一次提交"

image.png

7、将本地的仓库关联到远程仓库,如github
输入 git remote add origin ssh地址 https地址也行
image.png

8、上传github之前,要先pull一下
输入 git pull origin master
image.png

9、上传代码到github远程仓库
输入 git push -u origin master
image.png
10、坐等上传完毕

问题一:

由于没有在远程仓库添加密钥,用ssh方式克隆被拒绝.png

在指定目录生成key .png

推荐默认生成,
上图是,在电脑新建文件夹GitKey,然后打开git控制台,生成密钥key,如果不想指定生成路径,就把绿色框的内容去掉,默认生成路径为:[/user(当前电脑用户)/.ssh] , 如下图:

默认路径生成key.png

查看已生成的key,注意区别是否指定路径
非指定路径(推荐):cat ~/.ssh/id_rsa.pub
指定路径(不推荐):cat …/GitKey/id_rsa.pub

非指定路径的查看key.png

指定路径的查看key.png

推荐默认生成,简便式解决:


$ git pull origin master
git@gitee.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

解决:
1、生成公钥:ssh-keygen -t rsa -C "xxx@qq.com"
2、三次点击enter键
3、查看公钥:cat ~/.ssh/id_rsa.pub
4、到gitee上或者github上添加公钥的个人私钥
5、添加后,在终端(Terminal)中输入:ssh -T git@gitee.com
      看到Welcome to Gitee.com, yourname!则表明成功

问题二:

hint: Updates were rejected because the tip of your current branch is behind
hint: 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.

有如下几种解决方法:

1.使用强制push的方法:

$ git push -u origin master -f 

这样会使远程修改丢失,一般是不可取的,尤其是多人协作开发的时候。

2.push前先将远程repository修改pull下来

$ git pull origin master

$ git push -u origin master

3.若不想merge远程和本地修改,可以先创建新的分支:

$ git branch [name]

然后push

$ git push -u origin [name]

问题三:

就是 clone 的时候 SSH 的地址拉不起来,然后http方式clone的时候可以,但是拉取失败、提交失败等情况

失败情况.png
正常情况.png
解决:Could not read from remote repository
https://help.github.com/en/articles/connecting-to-github-with-ssh

问题四:

image.png
解决办法:控制面板👉搜索 凭据管理器👉windows凭据👉普通凭据👉找到你要改的,修改账号和密码

image.png
image.png

更多查看码云使用手册
转Git仓库分支(Branch)和标签(Tag)
Git的4个阶段的撤销更改

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值