开源项目如何贡献代码

以腾讯犀牛鸟开源项目ncnn为例

目录

fork项目仓库

添加远程仓库

同步更新仓库

贡献代码提交新PR

PR未merge更新PR


fork项目仓库

只需要做一次

到仓库页面点击fork,然后create forkTencent/ncnn: ncnn is a high-performance neural network inference framework optimized for the mobile platform (github.com)icon-default.png?t=N6B9https://github.com/Tencent/ncnn

到自己fork的仓库复制下自己的仓库地址GitHub - YEZIPRO/ncnn: ncnn is a high-performance neural network inference framework optimized for the mobile platformncnn is a high-performance neural network inference framework optimized for the mobile platform - GitHub - YEZIPRO/ncnn: ncnn is a high-performance neural network inference framework optimized for the mobile platformhttps://github.com/YEZIPRO/ncnn.git 到本地git工具命令本仓库

git clone https://github.com/YEZIPRO/ncnn.git

拉取若出现 Failed to connect to github.com port 443 after 21096 ms: Couldn't connect to server 问题,使用命令解决

git config --global --unset http.proxy

或者这个解决

git config --global --unset https.proxy

添加远程仓库

只需要做一次

进入项目仓库

cd ncnn

将原始仓库添加为本地仓库的远程仓库

git remote add upstream https://github.com/Tencent/ncnn.git

同步更新仓库

跟上原始仓库的变化

进入仓库

cd ncnn

将当前分支切换到master分支

git checkout master

从远程原始仓库获取最新的代码更新

git fetch upstream

若出现  Recv failure: Connection was reset 问题,使用下面两种方法解决

git config --global --unset http.proxy

或这个

git config --global --unset https.proxy

将远程原始仓库的master分支合并到当前分支

git merge upstream/master

推送到自己的GitHub仓库

git push

可能需要密码登录验证授权 

贡献代码提交新PR

先同步原始仓库,即上一个模块讲的东西

GitHub上自己的仓库新建分支,比如叫pnnx-torch-cross

常规进入项目

cd ncnn

 获取最新的更新

git pull

切换到新建分支

git checkout pnnx-torch-cross

coding……

提交代码到暂存区

git add .

创建一个提交

git commit -m "提交信息"

推送到自己的GitHub仓库

git push

在GitHub自己仓库切换到新建分支,点击create pull request提交新PR

PR未merge更新PR

进入项目仓库

cd ncnn

切换到该分支

git checkout pnnx-torch-cross

获取原始仓库最新代码

git fetch upstream

将原始仓库master分支合并至当前分支

git merge upstream/master

修改代码coding……

提交代码到暂存区

git add .

创建一个提交

git commit -m "提交信息"

推送到自己的GitHub仓库

git push

猜你喜欢

转载自blog.csdn.net/weixin_62264287/article/details/132153057