在这里以作业:高级操作系统作业为例子
参考文献:用vscode提交代码到Gitee
上传本地项目代码到Gitee或Github_powered by gitee.com-CSDN博客
一、找到需要提交PR的仓库,将其fork到我们的Gitee远程仓库
pr 是 pull request 的缩写,是一种在代码协作平台上提交代码修改的方式。pr 可以让其他人查看和评审你的代码,然后决定是否接受你的修改。
fork:指的是从官网仓库中复制一份拷贝到自己的账号仓库下,在这个时间节点下两者的内容一致;后续需要不断的手动完成同步
这个是需要fork的仓库地址:ecmascript/compiler/trampoline/aarch64/asm_interpreter_call.cpp · OH RISC-V SIG/arkcompiler_ets_runtime - Gitee.com
二、将远程仓库里面的代码clone到本地仓库
fetch:指的是将官方账号仓库的内容拉取到本地
操作流程:Git代码到本地仓库
三、在本地仓库做出修改,然后上传到远程仓库
在仓库里面打开Git,我们默认处于Master分支中
3.1在本地仓库新建并切换到一个分支
git checkout -b BranchName
这个命令的作用是创建(-b),然后切换(checkout)到分支BranchName进行编辑
是以下两个命令的组合
git branch BranchName
创建分支BranchName
git checkout BranchName
切换到分支BranchName
此时就切换到了01分支,可以虽然是windows的系统,但是linux的命令都能用,Vim也可以
3.2 做修改
添加了一行gogogoggo
3.2 做出相应的修改(这里能不能用VScode呢?)
3.3 在分支中更新修改的文件
git add FileName
git status
使用git add命令确定更改的文件,然后git status查看更改
3.4 将更改提交到本地仓库
commit:指的是将克隆的代码,根据需要修改更正某些内容或者增加新内容、删除冗余内容,形成记录
git commit -m MassageAboatCommit
MassageAboatCommit是关于这次提交的简要介绍,如果出现如下报错
git config --global user.name "Irving"
git config --global user.email "yuanyan23@mails.ucas.ac.cn"
需要在Gitee找到自己的用户名和邮箱,然后分别填在双引号内,具体位置如下图所示
3.5 将更改更新到自己的远程仓库
git push -f
出现这个报错
直接执行提示的代码就可以了
git push --set-upstream origin 01
出现报错,输入账号密码即可,账号是手机号
显示关联分支成功
然后再次使用 git push -f 即可上传成功
可以在Gitee上面看到分支,并且在README.md里面看到改动
四、提交PR
merge:英文意思是“合并”,指的是官方账号仓库的 commiter 接受了你的修改,将其合并到主线上
首先,进入到本地的远程仓库,确认是01分支,确实是自己的远程仓库,然后点击Pull Request
找到提交地址:Pull Requests · OH RISC-V SIG/arkcompiler_ets_runtime - Gitee.com
对于vscode
先新建一个远程仓库
得到一个仓库地址Irving/arkcomplier_ets_runtime_pr
在vscode添加远程仓库
在圈起来的位置点击之后上传
idea中将代码上传到gitee_哔哩哔哩_bilibili这个视频可能有用
提交pr的分支应该是weekly_20230905
$ git commit -m
fatal: could not parse HEAD
这个报错的解决方案是
git symbolic-ref HEAD refs/heads/master
回到主分支
从一个仓库跳转到另一个仓库
$ git checkout origin/master
然后可以再创建或者切换分支,origin是在本地仓库设置的,给远程仓库的别名
创建新的仓库,并且在本地起别名
把默认仓库改成https://gitee.com/irving_yuan/arkcompiler_ets_runtime.git
git remote set-url origin https://gitee.com/irving_yuan/arkcompiler_ets_runtime.git
git remote -v可以查看所有的别名和仓库的地址 的对应关系
CommitPR https://gitee.com/irving_yuan/arkcompiler_ets_runtime.git (fetch)
CommitPR https://gitee.com/irving_yuan/arkcompiler_ets_runtime.git (push)
commit_pr https://gitee.com/irving_yuan/arkcompiler_ets_runtime.git (fetch)
commit_pr https://gitee.com/irving_yuan/arkcompiler_ets_runtime.git (push)
ets_pr https://gitee.com/irving_yuan/arkcomplier_ets_runtime_pr.git (fetch)
ets_pr https://gitee.com/irving_yuan/arkcomplier_ets_runtime_pr.git (push)
origin https://gitee.com/irving_yuan/arkcompiler_ets_runtime.git (fetch)
origin https://gitee.com/irving_yuan/arkcompiler_ets_runtime.git (push)
origin_ets https://gitee.com/irving_yuan/arkcomplier_ets_runtime_pr.git (fetch)
origin_ets https://gitee.com/irving_yuan/arkcomplier_ets_runtime_pr.git (push)