Github: Pull request全流程及报错解决

注:PowerShell 比 cmd 和 Git Bash 好用!!

(一)本地修改代码

1.下载文件

eg. 点击"code"

方法一:win+r —— cmd —— 在终端输入“git clone + url”;

方法二:直接点击“download zip”

2.在本地IDE等修改代码

(二)上传代码-pull request

1.fork原仓库

2.打开“Git Bash”

3.打开文件——输入命令:“cd+路径”

eg.

$ cd "D:\文件夹具体路径"

4.创建新分支

$ git checkout -b 新分支名称

报错1:fatal: not a git repository (or any of the parent directories): .git

解决:初始化

$ git init
输出:Initialized empty Git repository in D:/文件夹/.git/
 

输出:Switched to a new branch 'NewBranch'

5.查询状态,确定已建立分支

$ git status
输出:On branch NewBranch

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .gitignore
        README.md
       ……

nothing added to commit but untracked files present (use "git add" to track)

6.添加to commit

$ git add .
输出:一大堆的warning,如

warning: in the working copy of 'windows/文件', LF will be replaced by CRLF the next time Git touches it

 

7.commit,提交信息

$ git commit -m "submitting new code"
输出:[NewBranch (root-commit) xxxxxxx] 文件夹
 xxx files changed, xxxxx insertions(+)
 create mode xxxxxx .gitignore
……很多的create

8.push到分支

$ git push origin 分支名

报错2: fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

解决:将远程仓库添加到当前的Git项目中

$ git remote add origin https://github.com/quanttide/qtcloud-collab-studio

报错3:info: please complete authentication in your browser...
remote: Permission to quanttide/qtcloud-collab-studio.git denied to Voskamp099.
fatal: unable to access 'https://github.com/quanttide/qtcloud-collab-studio/': The requested URL returned error: 403

解决:去掉之前配置的代理

$ git config --global --unset http.proxy
$ git config --global --unset https.proxy【未解决问题】

解决1:远程仓库的URL设置

$ git remote set-url origin https://token@github.com/Voskamp099/Repo

或 $ git remote set-url origin git@github.com:Voskamp099/Repo.git

【请一定检查你的github账号里仓库名叫什么!!名字错会导致地址错误】

解决2:查询当前已配置远程仓库

$ git remote -v 

输出:origin  https://token@github.com/Voskamp099/Repo (fetch)
origin  https://token@github.com/Voskamp099/Repo (push)

解决3:配置ssh key

$ ls -al ~/.ssh

输出:total 47
……

……  (如果暂无ssh key,请上网查询如何创建)

配置SSH代理

$ eval "$(ssh-agent -s)"
输出:Agent pid xxxx

查找rsa-ssh的文件位置

$ ssh-add ~/.ssh/id_rsa
输出:Identity added: /c/路径  (邮箱)

配置SSH

$ ssh -T git@github.com
输出:Hi Voskamp099! You've successfully authenticated, but GitHub does not provide shell access.

通过文件路径找到rsa-ssh文件,复制文件内容,保存在github账号个人设置中的SSH & GPG Keys【不知道有没有用】

报错4:The authenticity of host 'github.com' can't be established.
xxx key fingerprint is xxxxx.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])?

yes

解决1:这块好像有一个问题是ssh配置时内容把ssh-rsa删了…github上指明了要以“ssh-rsa”等前缀开头。

解决2:键入yes,会执行一个文件之间的connect。

报错5:Warning: Permanently added 'github.com' to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
 

(三)pull-request栏目

1.可以看到“pull request”的提示

base repository是你希望合并更改的目标仓库和分支,而head repository指的是你修改完的代码所在的仓库和分支。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值