1.初始化仓库
git init
2.关联仓库
git remote add origin <仓库ssh地址>
3.新建并选择新的本地分支(与远程分支一致)
git checkout -b 分支名称(一般是main或者master,优先使用master)
4.添加全部文件(第一次push代码之后,从第二次开始就不要再搞前面的了,之前已经绑定过了)
git add .
5.提交信息
git commit -m "备注信息"
6.强制推送
git push -f origin 分支名称
如果不幸遇到这种恶心的问题:
admin@DESKTOP-TNI5ROV MINGW64 /d/git/rt-thread/rt-thread_pm2
$ git log
fatal: detected dubious ownership in repository at 'D:/git/rt-thread/rt-thread_pm2'
'D:/git/rt-thread/rt-thread_pm2' is owned by:
'S-1-5-21-1045045257-1974506225-3199486363-500'
but the current user is:
'S-1-5-21-1045045257-1974506225-3199486363-1001'
To add an exception for this directory, call:
git config --global --add safe.directory D:/git/rt-thread/rt-thread_pm2
请参考:
https://blog.csdn.net/tcjy1000/article/details/127129224?login=from_csdn