在本地创建一个空文件夹

命名随意

gitlab导入repo_git

将Gitea仓库地址复制下来

gitlab导入repo_gitlab导入repo_02

在刚刚空文件夹 git 下右键打开Git Bash Here

gitlab导入repo_git_03

在命令里面克隆地址

git clone Gitea仓库地址

gitlab导入repo_文件名_04


本地就会在git文件夹下看见克隆的这个文件名

gitlab导入repo_gitea_05

将要上传的项目文件复制到该文件夹下

gitlab导入repo_git_06

在git命令里面操作

先执行初始化,输入 git init,回车。

gitlab导入repo_文件名_07

执行 git add 文件名 (如果是git add . 表示当前目录下的所有内容),注意,add后要一个空格

git add 文件名

此时会报错:fatal: pathspec 'available_models' did not match any files,是因为当前命令的目录没有切换到仓库目录下。

cd 仓库名称/

gitlab导入repo_git_08


然后重新执行 git add 文件名,此时有一个警告:warning: in the working copy of 'available_models/conf.json', LF will be replaced by CRLF the next time Git touches it。 解决办法参考这里 我这里用到了其中一种:git config --global core.autocrlf input

这里注意,需要把之前add到缓存区的东西删掉再重新传。删除相关缓存:git rm -r --cached 文件夹名称

可用git ls-files 查看缓冲区文件。若是返回为空,那就是没有文件。

全部 add 完成过后,需commit

git commit -m "第一次提交"

这里若第一次使用git会报错,没有输入账号。

gitlab导入repo_git_09


根据提示输入邮箱和名称即可

gitlab导入repo_git_10

git config --global user.email "xxx.com"
git config --global user.name "xxx"

再次commit

gitlab导入repo_github_11

提交代码到Gitea

git remote add origin 仓库地址

此时可能会报错:error: remote origin already exists. 因为我们先前连接了远程地址,这里就需要先删除关联的 origin 远程库。

git remote rm origin

gitlab导入repo_文件名_12


再次执行remote。

gitlab导入repo_gitlab导入repo_13


上传完后,刷新Gitea仓库即可看见刚刚上传的文件。

gitlab导入repo_github_14