[Github] 新建仓库连接远程仓库流程 #待补充
[!question]
温习一下流程
[!success] 流程如下, 注意有报错其实可以直接去问
gpt
, 一般都可以解决问题,.git
文件夹会保留所有信息包括commit
的message
, 带动源代码的时候记得带走.git
, 它是仓库核心
git init
git remote add origin add origin https://github.com/...
git branch # 查看本地分支
git
[Github] error: failed to push some refs to “…”
[!bug]
这个错误提示是因为 GitHub 上的 master 分支已经有内容,而您的本地分支尚未同步这些内容。
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/odddouglas/rt-thread-custom_repack_lib.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
[!success] 取远程分支内容:将远程的 main 分支内容拉取到本地。
- 这会将远程
master
分支的更改合并到本地master
分支中。如果有冲突,Git 会提示解决冲突,您需要手动解决冲突并继续。
git pull origin master --rebase
- 在解决冲突并完成合并后,再尝试推送本地分支。
git push origin master
[RT-Thread] 尝试对源码进行再封装
[!question]
封装的时候出现无法索引到源文件的情况
将函数的声明写在了
rtrepack.h
文件, 并放在源码文件夹的include
文件夹, 路径为E:\ODDDOUGLAS\maxi-file\rtthread\rtthread-5.1.0\rt-thread\include
, 此时是可以被工程检索到的, 但是函数的具体定义repack.c
,却无法被正常检索
[!success] 因此我把具体的函数定义都写在了
rtrepack.h
这个头文件中,并仿照include
目录下的其他头文件, 规范了格式.
/*
* Copyright (c) 2024 odddouglas
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2024-11-12 odddouglas the first version
*/
#ifndef __RT_REPACK_H__
#define __RT_REPACK_H__
#include <rtdbg.h>
#include <board.h>
#include <rtthread.h>
#include <drv_gpio.h>
#include <rtdef.h>
#include <rtconfig.h>
/**
* @brief
*
* @param[in,out]
* @param[in]
* @return
* @note
*/
void func_name()
{
//...
}
#endif
新建了一个专门的仓库,路径为
E:\ODDDOUGLAS\maxi-file\rtthread\rtthread-5.1.0\rt-thread\include\repacklib
, 用于存放RT-Thread相关的封装代码库, 平时都会在vsc的stm32l475-atk-pandora
工作区中进行源码学习, 可以打开终端进行以下操作
cd ../../..//include/repacklib
git add .
git commit -m "feat: add function <semaphore_generate>|Create or initialize a semaphore that supports both dynamic and static creation."
git push
[Github] 完善commit的message格式
[!question]
如何规范git提交的信息格式
[!success] 以下是格式, 分为
Header
,Body
,Footer
Header: <type>(<scope>): <subject>
- type: 代表 commit 的類別:feat, fix, docs, style, refactor, test, chore,必要欄位。
- scope 代表 commit 影響的範圍,例如資料庫、控制層、模板層等等,視專案不同而不同,為可選欄位。
- subject 代表此 commit 的簡短描述,不要超過 50 個字元,結尾不要加句號,為必要欄位。
Body: 72-character wrapped. This should answer:
* Body 部份是對本次 Commit 的詳細描述,可以分成多行,每一行不要超過 72 個字元。
* 說明程式碼變動的項目與原因,還有與先前行為的對比。
Footer:
- 填寫任務編號(如果有的話).
- BREAKING CHANGE(可忽略),記錄不兼容的變動,
以 BREAKING CHANGE: 開頭,後面是對變動的描述、以及變動原因和遷移方法。
type
只允許使用以下類別
feat: 新增/修改功能 (feature)。
fix: 修補 bug (bug fix)。
docs: 文件 (documentation)。
style: 格式 (不影響程式碼運行的變動 white-space, formatting, missing semi colons, etc)。
refactor: 重構 (既不是新增功能,也不是修補 bug 的程式碼變動)。
perf: 改善效能 (A code change that improves performance)。
test: 增加測試 (when adding missing tests)。
chore: 建構程序或輔助工具的變動 (maintain)。
revert: 撤銷回覆先前的 commit 例如:revert: type(scope): subject (回覆版本:xxxx)。
当然也可以很简易
type: description|filename
[Github] 解决上传时用户信息不对应
[!question]
解决GitHub提交时不显示自己的头像 显示另一个账号(其实也是自己)
[!success] 查看邮箱和用户名
git show
看看是否是自己的githup 账号的邮箱 如果不是进行下列操作git config user.email
“你的邮箱地址”,修改邮箱- 修改完以后输入
git config user.email
检查是否修改成了你的邮箱
git config --global user.name “odddouglas”
git config --global user.email 18718048671iota@gmail.com
[RT-Thread] 封装出现了空指针情况
[!bug]
这个错误提示表示在调用 rt_thread_startup 函数时,传入的线程指针 thread 是 RT_NULL(即空指针),导致断言失败。通常情况下,这个问题出现在以下几种情况中:
(thread != RT_NULL) assertion failed at function:rt_thread_startup, line number:395
rt_backtrace is not implemented
源代码
// 线程相关变量
rt_thread_t th1_ptr = RT_NULL;
struct rt_thread th2; // 静态创建线程控制块
rt_uint8_t th2_stack[512] = {0};
int main(void)
{
thread_generate(th1_ptr,
"th1_demo",
th1_entry,
RT_NULL,
RT_NULL,
1024, 20, 5, RT_TRUE);
thread_generate(&th2,
"th2_demo",
th2_entry,
RT_NULL,
th2_stack,
sizeof(th2_stack), 19, 5, RT_FALSE);
rt_thread_startup(th1_ptr);
rt_thread_startup(&th2);
return 0;
}
rt_err_t thread_generate(struct rt_thread *th_ptr,
const char *name,
void (*entry)(void *parameter),
void *parameter,
void *stack_addr,
rt_size_t stack_size,
rt_uint8_t priority,
rt_uint8_t tick,
rt_bool_t is_dynamic)
[!success] 可以使用二级指针的方式来传递
th_ptr
,确保在主程序中传递的指针可以被正确赋值, 仅展示主程序中的传参情况, 注意与源代码的区别, 此时传入的参数已经发生更变, 具体的函数内部实现请自行查阅(其实就是改了参数)
// main.c
// 线程相关变量
rt_thread_t th1_ptr = RT_NULL;
struct rt_thread th2; // 静态创建线程控制块
rt_thread_t th2_ptr = &th2;
rt_uint8_t th2_stack[512] = {0};
int main(void)
{
thread_generate(&th1_ptr,
"th1_demo",
th1_entry,
RT_NULL,
RT_NULL,
1024, 20, 5, RT_TRUE);
thread_generate(&th2_ptr,
"th2_demo",
th2_entry,
RT_NULL,
th2_stack,
sizeof(th2_stack), 19, 5, RT_FALSE);
rt_thread_startup(th1_ptr);
rt_thread_startup(th2_ptr);
return 0;
}
具体函数实现
rt_err_t thread_generate(rt_thread_t *th_ptr, //只改了这一行
const char *name,
void (*entry)(void *parameter),
void *parameter,
void *stack_addr,
rt_size_t stack_size,
rt_uint8_t priority,
rt_uint8_t tick,
rt_bool_t is_dynamic)