仓库完整迁移-代码,分支,提交记录
第1种镜像迁移
//拷贝镜像到本地
git clone --mirror xxUrl xxLocal
//镜像设置远程地址
cd xxLocal
git remote set-url --push origin http://192.x.x.x/client/xxx.git
//推送到远程
git push --mirror
//本地仓库管理远程地址
git remote set-url origin http://192.x.x.x/client/xxx.git
gitlab推送失败 由于默认只有main分支 并且设置保护了;需要增加master分支
第2种 直接推送远程新仓库
//本地代码分支(master) push远程 分支(dev1 新创建)
git remote set-url --push origin xxx.git
git push origin master:dev1
参照
https://blog.youkuaiyun.com/liyuerge/article/details/88638785
git 获取最后一次提交时间和commit id通过bat/cmd命令赋给变量
获取最后一次提交时间
git show --pretty=format:"%ci %cr" | head -1
2021-04-07 15:06:17 +0800 2 hours ago
获取最后一次提交的commit Id
git rev-parse HEAD
31cab83b6cc7b844dc407291d47ac72f1d495690
获取最后一次提交的short commit Id
git rev-parse --short HEAD
31cab83b6
linux系统下,需要执行下面的命令:
commitid=`git rev-parse --short HEAD`
echo commitid=$commitid
windows系统下,要使用for命令:
for /F %%i in ('git rev-parse --short HEAD') do ( set commitid=%%i)
echo commitid=%commitid%
Git操作大全
git clean 的用法详解_一定要学_一定要慎用_不头秃的码农的博客-优快云博客
git深入理解(一):暂存区(Stage),索引(index)_git index_raoxiaoya的博客-优快云博客
git深入理解(二):HEAD是什么_git head_raoxiaoya的博客-优快云博客
git深入理解(三):git diff详解_raoxiaoya的博客-优快云博客
git深入理解(四):git log详解_git logs_raoxiaoya的博客-优快云博客
git深入理解(六):git checkout详解_git checkout ._raoxiaoya的博客-优快云博客