• 【MMDet】提交PR的学习笔记


    官方文档

    关于如何向MMDet提交PR,请参考mmcv的文档《拉取请求 — mmcv 1.6.1 文档》

    1. Fork最新代码库

    当第一次提PR时,需要复刻OpenMMLab代码库,点击 GitHub 页面右上角的Fork按钮即可
    在这里插入图片描述
    将复刻的代码库克隆到本地

    git clone fork_mmdetection_git
    
    • 1

    设置官方repo为上游代码库

    git remote add upstream official_mmdetection_git
    
    • 1

    Note
    这里的upstream是远程仓库的名称(),类似于备注。

    2. 切换到默认主分支

    查看本地所有分支

    git branch
    
    • 1

    3. Pre-commit预处理(在git-add-commit之前进行)

    因为pre-commit会对MD文件进行格式化,从而对文件内容进行修改,这些修改也是需要被索引然后提交的,所以pre-commit需要在git-add-commit之前进行;

    安装pre-commit工具

    python -m pip install pre-commit -i https://pypi.doubanio.com/simple
    
    • 1

    进行提交前的预处理

    pre-commit run --all-files
    
    • 1

    4. 提交代码修改

    将修改的文件加入缓存区

    git add [files]
    
    • 1

    将所有已修改的文件加入缓存区提交

    git add .
    
    • 1

    提交修改

    git commit -m "decribe_the_changes"
    
    • 1

    5. 向远程仓库推送修改

    git push origin local_dev
    
    • 1

    第一次push:还需要在自己的 fork-repo 中手动点击按钮创建PR;
    第二次push:GitHub会自动将修改推送到PR中,不需要手动进行更新了。

    Troubleshooting

    (1) Error: failed to push some refs to ‘https://github.com/…/mmdetection.git’, hint: Updates were rejected because the tip of your current branch is behind, …

    在推送修改时,出现了这样的错误提示:

    To https://github.com/…/mmdetection.git
    ! [rejected] 3.x_doc -> 3.x_doc (non-fast-forward)
    error: failed to push some refs to ‘https://github.com/…/mmdetection.git’
    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.

    引起这个错误的原因是,上游仓库已经添加了新的内容,(为了防止推送出现conflict),远程仓库拒绝了推送;
    这里我们需要首先 git-pull更新本地的仓库,然后再进行修改;

    (2) 如果在“pre-commit run --all-files”编译无法通过的时候,可以将python环境切换到python3.7进行编译

    因为格式化包中用到了 typed_ast 包,而这个包的repo在文档中声明不支持python3.8以上的版本,所以需要使用python3.7进行编译;

  • 相关阅读:
    jenkins gitlab CI/CD
    Head First设计模式(阅读笔记)-02.观察者模式
    使用 VPN ,一定要知道的几个真相!
    剑指offer--重建二叉树
    [Cocos 3.5.2]开启模型合批
    基于Flask的岗位就业可视化系统(总)
    [Linux] GRUB引导 学习笔记(一)
    【C++】模版进阶
    华为机试-极限法(分苹果。剪绳子)
    金仓数据库 KingbaseGIS 使用手册(8.4. 栅格存取函数)
  • 原文地址:https://blog.csdn.net/songyuc/article/details/127914755