迁移本地git到远程
迁移本地git到远程,
可以保留提交记录,
但是没有分支,这个可以自己下载分支code,再提交所有分支到new git。 //或者保留 所有diff 或者commit 文件
参考
https://blog.csdn.net/github_38336924/article/details/118544619
第一步,从远程仓库克隆到本地//先下载source 仓库到本地
git clone https://github.com/oldxxx/oldxxx.git
第二步,删除需要迁移的本地项目所关联的远程仓库地址 (在本地source仓库,输入以下命令删除关联)
git remote remove origin
第三步,关联新仓库的地址
git remote add origin https://github.com/newxxx/newxxx.git
第四步,把项目推送到新的远程仓库 //其实这步, 已经把old git提交记录, 迁移到new git了
git push
第五步,从原仓库地址克隆一份裸版本库
git clone --bare https://github.com/oldxxx/oldxxx.git
第六步,原仓库所有分支同步新仓库
git push --mirror https://github.com/newxxx/newxxx.git
example:
//old repo =>local git folder
d/pro/MyGitRepo/oldxxx
//new repo =>remote
https://git.com/xxx2022/newxxx.git 是私有的
============================================
操作实例:
$cd /d/pro/MyGitRepo/oldxxx
$ git clone [old git repo]
test@DESKTOP-8953GMH MINGW64 /d/pro/MyGitRepo/oldxxx (master)
$ git remote remove origin
test@DESKTOP MINGW64 /d/pro/MyGitRepo/xxx (master)
$ git remote add origin https://gitee.com/xxx2022/newxxx.git
test@DESKTOP MINGW64 /d/pro/MyGitRepo/xxx (master)
$ git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
test@DESKTOP MINGW64 /d/pro/MyGitRepo/xxx (master)
$ git push --set-upstream origin master
remote: [session-1946ecb0] ?????@??.com: Incorrect username or password (access token)
fatal: Authentication failed for 'https://github.com/xxx2022/newxxx.git'
test@DESKTOP MINGW64 /d/pro/MyGitRepo/xxx (master)
$ git push --set-upstream origin master
Enumerating objects: 413, done.
Counting objects: 100% (413/413), done.
Delta compression using up to 20 threads
Compressing objects: 100% (223/223), done.
Writing objects: 100% (413/413), 1.06 MiB | 642.00 KiB/s, done.
Total 413 (delta 229), reused 339 (delta 178), pack-reused 0
remote: Resolving deltas: 100% (229/229), done.
remote: Powered by github.COM [GNK-6.4]
To https://github.com/xxx2022/newxxx.git
* [new branch] master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
test@DESKTOP MINGW64 /d/pro/MyGitRepo/xxx (master)
$