最新消息:20210917 已从crifan.com换到crifan.org

【记录】Gitlab中git仓库mitmdumpUrlSaver整体迁移到新git仓库且保留历史记录

Git crifan 245浏览 0评论
折腾:
【已解决】Gitlab的旧git仓库迁移到新仓库且保留commit历史记录
后,继续去整体迁移另外一个git仓库:
原先的:
Data / data_xxx / mitmdumpUrlSaver · GitLab
希望迁移到:
http://gitlab.xxx.corp.com/data_xxx/mitmdumpurlsaver
去操作:
xxx@xxx  ~/dev/xx/crawler/appAutoCrawler/gitlab/transfer  git clone --mirror 
http://xxx.corp.com:xxx/data/data_xxx/mitmdumpurlsaver.git
 mitmdumpUrlSaver
Cloning into bare repository 'mitmdumpUrlSaver'...
remote: Enumerating objects: 178, done.
remote: Counting objects: 100% (178/178), done.
remote: Compressing objects: 100% (91/91), done.
remote: Total 178 (delta 91), reused 131 (delta 69)
Receiving objects: 100% (178/178), 30.32 MiB | 1.68 MiB/s, done.
Resolving deltas: 100% (91/91), done.
去看看文件:
 xxx@xx  ~/dev/xx/crawler/appAutoCrawler/gitlab/transfer  cd mitmdumpUrlSaver
 xxx@xx  ~/dev/xx/crawler/appAutoCrawler/gitlab/transfer/mitmdumpUrlSaver   master  ll
total 32
-rw-r--r--   1 xxx  CORP\Domain Users    23B  7 16 10:41 HEAD
-rw-r--r--   1 xxx  CORP\Domain Users   244B  7 16 10:41 config
-rw-r--r--   1 xxx  CORP\Domain Users    73B  7 16 10:41 description
drwxr-xr-x  13 xxx  CORP\Domain Users   416B  7 16 10:41 hooks
drwxr-xr-x   3 xxx  CORP\Domain Users    96B  7 16 10:41 info
drwxr-xr-x   4 xxx  CORP\Domain Users   128B  7 16 10:41 objects
-rw-r--r--   1 xxx  CORP\Domain Users   105B  7 16 10:41 packed-refs
drwxr-xr-x   4 xxx  CORP\Domain Users   128B  7 16 10:41 refs
删除远端分支
 xxx/transfer/mitmdumpUrlSaver   master  git remote remove origin
Note: A branch outside the refs/remotes/ hierarchy was not removed;
to delete it, use:
  git branch -d master
先新建新的git仓库:
git地址:
http://xxx.corp.com:xxx/data_xxx/mitmdumpurlsaver.git
继续:
  git remote add origin 
http://xxx.corp.com:12310/data_xxx/mitmdumpurlsaver.git
以及上传:
xxx@xxx  ~/dev/xx/crawler/appAutoCrawler/gitlab/transfer/mitmdumpUrlSaver   master  git push --all
Enumerating objects: 178, done.
Counting objects: 100% (178/178), done.
Delta compression using up to 8 threads
Compressing objects: 100% (69/69), done.
Writing objects: 100% (178/178), 30.32 MiB | 175.38 MiB/s, done.
Total 178 (delta 91), reused 178 (delta 91)
remote: Resolving deltas: 100% (91/91), done.
To 
http://xxx.corp.com:xxx/data_xxx/mitmdumpurlsaver.git
 * [new branch]      master -> master
 xxx@xx  ~/dev/xx/crawler/appAutoCrawler/gitlab/transfer/mitmdumpUrlSaver   master  git push --tags
Everything up-to-date
然后去原本地代码中,更换远程仓库url
 xxx@xxx  ~/dev/xxx/crawler/mitmdumpUrlSaver   master  git remote -vorigin  
http://xxx:12310/data/data_xxx/mitmdumpurlsaver.git
 (fetch)
origin  
http://xxx:12310/data/data_xxx/mitmdumpurlsaver.git
 (push)
 xxx@xxx  ~/dev/xxx/crawler/mitmdumpUrlSaver   master  git remote set-url origin 
http://xxx:12310/data_xxx/mitmdumpurlsaver.git
 xxx@xxx  ~/dev/xxx/crawler/mitmdumpUrlSaver   master  git remote -vorigin  
http://xxx:12310/data_xxx/mitmdumpurlsaver.git
 (fetch)
origin  
http://xxx:12310/data_xxx/mitmdumpurlsaver.git
 (push)
即可。
然后去随便改动点内容,上传一下,看看是否正常。
结果报错了:
 xxx@xxx  ~/dev/xxx/crawler/mitmdumpUrlSaver   master ●  git add * 
The following paths are ignored by one of your .gitignore files:
for_debug
venv
Use -f if you really want to add them.
 ✘ xxx@xxx  ~/dev/xxx/crawler/mitmdumpUrlSaver   master ✚  git commit -m "1. update readme"[master 621c5c0] 1. update readme
 1 file changed, 9 insertions(+), 6 deletions(-)
 xxx@xxx  ~/dev/xxx/crawler/mitmdumpUrlSaver   master  git push                        
To 
http://xxx:12310/data_xxx/mitmdumpurlsaver.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to '
http://xxx:12310/data_xxx/mitmdumpurlsaver.git
'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
根据提示去pull试试:
  git pull
Auto-merging README.md
CONFLICT (content): Merge conflict in README.md
Automatic merge failed; fix conflicts and then commit the result.
结果发现很多文件有更新:
且VSCode支持:
当auto-merge时出现的冲突
显示出额外的动作:
点击:
采用当前更改
即可用最新改动的内容了。
然后继续提交新改动内容:
结果无法提交,因为有未合并的内容:
Git: Committing is not possible because you have unmerged files.
点击了 打开Git日志
只看到最近一些操作对应日志
> git fetch
> git cat-file -s 683d798b9b48ecc6677ba7a5440254d20600cf1b
> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse master
> git rev-parse --symbolic-full-name master@{u}
> git rev-list --left-right master...refs/remotes/origin/master
> git for-each-ref --sort -committerdate --format %(refname) %(objectname)
> git remote --verbose
> git ls-tree -l HEAD -- /Users/xxx/dev/xxx/crawler/mitmdumpUrlSaver/electron-python-example/main.js
> git ls-files --stage -- /Users/xxx/dev/xxx/crawler/mitmdumpUrlSaver/electron-python-example/main.js
> git show --textconv HEAD:electron-python-example/main.js
> git cat-file -s 683d798b9b48ecc6677ba7a5440254d20600cf1b
> git show --textconv :electron-python-example/main.js
> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse master
> git rev-parse --symbolic-full-name master@{u}
> git rev-list --left-right master...refs/remotes/origin/master
> git for-each-ref --sort -committerdate --format %(refname) %(objectname)
> git remote --verbose
> git ls-tree -l HEAD -- /Users/xxx/dev/xxx/crawler/mitmdumpUrlSaver/electron-python-example/main.js
> git ls-files --stage -- /Users/xxx/dev/xxx/crawler/mitmdumpUrlSaver/electron-python-example/main.js
> git cat-file -s 683d798b9b48ecc6677ba7a5440254d20600cf1b
> git show --textconv :README.md
> git ls-files --stage -- /Users/xxx/dev/xxx/crawler/mitmdumpUrlSaver/README.md
> git cat-file -s b9f9c734dc30b027964203edf9e8c63917d30e68
没看到有哪些提示 conflict的东西啊?
算了,还是命令行操作:
 ✘ xxx@xxx  ~/dev/xxx/crawler/mitmdumpUrlSaver   master ●✚ >M<  git status
On branch master
Your branch and 'origin/master' have diverged,
and have 1 and 3 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)


You have unmerged paths.
  (fix conflicts and run "git commit")
  (use "git merge --abort" to abort the merge)


Changes to be committed:


        modified:   .gitignore
        modified:   .vscode/settings.json
        new file:   electron-python-example/clean_all.bat
        new file:   electron-python-example/clean_electron.bat
        new file:   electron-python-example/clean_pyinstaller.bat
        new file:   electron-python-example/electron_package.bat
        modified:   electron-python-example/main.js
        modified:   electron-python-example/package.json
        new file:   electron-python-example/package_all.bat
        new file:   electron-python-example/pyinstaller_package.bat
        modified:   electron-python-example/pymitmdump/mitmdumpManage.py
        modified:   electron-python-example/pymitmdump/mitmdumpOtherApi.py
        modified:   electron-python-example/pymitmdump/mitmdumpStartApi.py
        modified:   electron-python-example/pymitmdump/mitmdumpUrlSaver.py
        new file:   electron-python-example/pymitmdump/urlSaverConfig.json


Unmerged paths:
  (use "git add <file>..." to mark resolution)


        both modified:   README.md
发现最底部一个是:
both modified
表示 本地和服务器 都修改了
即:auto-merge 自动合并 但是失败 出现 冲突conflict的情况
所以需要手动处理:刚才前面已手动处理完毕了。
所以现在可以去add进去了:
  master ●✚ >M<  git add README.md 
然后再去看状态就正常了:
 xxx@xxx  ~/dev/xxx/crawler/mitmdumpUrlSaver   master ✚ >M<  git status       
On branch master
Your branch and 'origin/master' have diverged,
and have 1 and 3 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)


All conflicts fixed but you are still merging.
  (use "git commit" to conclude merge)


Changes to be committed:


        modified:   .gitignore
        modified:   .vscode/settings.json
        modified:   README.md
        new file:   electron-python-example/clean_all.bat
        new file:   electron-python-example/clean_electron.bat
        new file:   electron-python-example/clean_pyinstaller.bat
        new file:   electron-python-example/electron_package.bat
        modified:   electron-python-example/main.js
        modified:   electron-python-example/package.json
        new file:   electron-python-example/package_all.bat
        new file:   electron-python-example/pyinstaller_package.bat
        modified:   electron-python-example/pymitmdump/mitmdumpManage.py
        modified:   electron-python-example/pymitmdump/mitmdumpOtherApi.py
        modified:   electron-python-example/pymitmdump/mitmdumpStartApi.py
        modified:   electron-python-example/pymitmdump/mitmdumpUrlSaver.py
        new file:   electron-python-example/pymitmdump/urlSaverConfig.json
然后就可以继续提交和上传了。
即可。
然后Gitlab中
data_xxx / mitmdumpUrlSaver · GitLab
内容显示已更新了:
至此,即可。

转载请注明:在路上 » 【记录】Gitlab中git仓库mitmdumpUrlSaver整体迁移到新git仓库且保留历史记录

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
98 queries in 0.157 seconds, using 21.63MB memory