第一步
本地新建一个文件夹 如test
第二步
在该文件夹下打开控制台, 执行 git init 将该文件夹变成一个git仓库
第三步
将你的项目文件移入到这个文件夹中,并在该文件夹的控制台中执行 git add --all,将所有文件添加到git中
第四步 添加远程仓库地址
在该文件夹的控制台中执行 git remote add 自定义仓库名 仓库地址
第五步 提交本地代码
在该文件夹的控制台中执行 git push 第四步自定义的仓库名 仓库分支名 即可
可能会遇到的错误
1、RLF will be replaced by LF in .github/workflows/sync.yml.
解决方法:
// 修改git全局配置,禁止git自动将lf转换成crlf
git config --global core.autocrlf false
// 配置全局git命令文件换行使用lf方式或者在terminal中对单个git代码仓库执行git config core.eol lf使用lf换行方式(这一步也可以不配置)
git config --global core.eol lf
// 提交时转换为lf,检出时不转换
git config --global core.autocrlf input
# 拒绝提交包含混合换行符的文件
git config --global core.safecrlf true
2、Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing
解决方法:
git pull 你的自定义远程仓库名 分支名 --allow-unrelated-histories
3、error: src refspec master does not match any
git commit -m "init"
然后 git remote add 你的自定义远程仓库名 你的远程仓库地址
再然后 git push -u 你的自定义远程仓库名 分支名