• 把gitosis-admin项目从一台机器迁移到另一台机器( git 2.30.2)


    一,在新机器上操作,生成免密登录的密钥:

    1,创建无需密码登录
    创建密钥
    liuhongdi@lhdpc:~# ls .ssh
    ls: 无法访问 '.ssh': 没有那个文件或目录
    生成密钥,一路回车即可
    liuhongdi@lhdpc:~# ssh-keygen -t rsa
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/liuhongdi/.ssh/id_rsa):
    Created directory ‘/home/liuhongdi/.ssh'.
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /home/liuhongdi/.ssh/id_rsa
    Your public key has been saved in /home/liuhongdi/.ssh/id_rsa.pub
    The key fingerprint is:
    SHA256:S7BiS23wnimJoEO/Z1XOVQxyXiu5r9O5fOgzhAVYrmM liuhongdi@lhdpc
    The key's randomart image is:
    +---[RSA 3072]----+
    |         .o+o.   |
    |         .=.oo.  |
    |    . .    =o.   |
    |     + o ...o.   |
    |..  + = SE..o    |
    |o..+ * =.+....   |
    |o ..+ = .   o.o  |
    | .  .+     .o* . |
    |   .o      .o+=  |
    +----[SHA256]——+
    查看是否生成了密钥
    liuhongdi@lhdpc:~# ls .ssh
    id_rsa  id_rsa.pub
    2,上传密钥到服务器
    liuhongdi@lhdpc:~# ssh-copy-id -i .ssh/id_rsa.pub -p 1888 webop@121.122.123.147
    /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: ".ssh/id_rsa.pub"
    /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
    /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
    webop@121.122.123.147's password:
     
    Number of key(s) added: 1
     
    Now try logging into the machine, with:   "ssh -p ‘1888’ 'webop@121.122.123.147'"
    and check to make sure that only the key(s) you wanted were added.
    3,测试无密码登录的效果
    liuhongdi@lhdpc:~# ssh -p ‘1888'webop@121.122.123.147'
     
    Welcome to Alibaba Cloud Elastic Compute Service !
     
    Activate the web console with: systemctl enable --now cockpit.socket
     
    Last login: Thu Sep 16 14:26:35 2021 from 124.220.178.199
    [webop@blog ~]$
     
    4,复制.ssh/id_rsa.pub为lhdnew.pub
    liuhongdi@lhdpc:~$ cp .ssh/id_rsa.pub javanew.pub 
    并复制到旧机器
     

    说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest

             对应的源码可以访问这里获取: https://github.com/liuhongdi/
             或: https://gitee.com/liuhongdi

    说明:作者:刘宏缔 邮箱: 371125307@qq.com

    二,在旧机器上操作:把javanew加入gitosis-admin项目,并提交

    1,复制javanew.pub到gitosis-admin/keydir/目录下
     
    2,修改gitosis.conf
    root@kubuntu:/data/git/gitosis-admin# vi gitosis.conf
    内容修改:
    为members增加javanew
    效果如下:
    [group gitosis-admin]
    members =  liuhongdi javanew
    writable = gitosis-admin 
    3,提交到代码服务器:
    root@kubuntu:/data/git/gitosis-admin# git status
    位于分支 master
    您的分支与上游分支 'origin/master' 一致。
    尚未暂存以备提交的变更:
      (使用 "git add <文件>..." 更新要提交的内容)
      (使用 "git checkout -- <文件>..." 丢弃工作区的改动)
            修改:     gitosis.conf
    未跟踪的文件:
      (使用 "git add <文件>..." 以包含要提交的内容)
            keydir/javanew.pub
    修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
    root@kubuntu:/data/git/gitosis-admin# git add -A
    root@kubuntu:/data/git/gitosis-admin# git commit -m "add java new";
    [master 241a0f2] add java new
    2 files changed, 10 insertions(+), 1 deletion(-)
    create mode 100644 keydir/javanew.pub
    root@kubuntu:/data/git/gitosis-admin# git status
    位于分支 master
    您的分支领先 'origin/master'1 个提交。
      (使用 "git push" 来发布您的本地提交)
    无文件要提交,干净的工作区
    root@kubuntu:/data/git/gitosis-admin# git push origin master
    4,查看remote,供在新机器下载项目时使用
    root@kubuntu:/data/git/gitosis-admin# git remote -v
    origin  ssh://git@121.122.123.147:1888/gitosis-admin.git (fetch)
    origin  ssh://git@121.122.123.147:1888/gitosis-admin.git (push)

    三,在新机器上操作:clone gitosis-admin这个项目

    克隆:

    liuhongdi@lhdpc:/data/git$ git clone ssh://git@121.122.123.147:1888/gitosis-admin.git
    查看效果
    liuhongdi@lhdpc:/data/git$ ls
    gitosis-admin

    四,在新机器上测试效果:添加一个gitosis管理的项目

    1,初始化一个项目:
    初始化
    liuhongdi@lhdpc:/data/vue/storeweb$ git init
    编辑gitignore,通常idea/webstorm之类的开发工具已经给建好了
    liuhongdi@lhdpc:/data/vue/storeweb$ vi .gitignore
    查看已添加的配置:
    liuhongdi@lhdpc:/data/vue/storeweb$ git config --global --list
    user.name=liuhongdi
    user.email=371125307@qq.com
    提交
    liuhongdi@lhdpc:/data/vue/storeweb$ git add -A
    liuhongdi@lhdpc:/data/vue/storeweb$ git commit -m "init project”;
    2,在gitosis中新加项目
    编辑gitosis.conf
     liuhongdi@lhdpc:/data/testgit/gitosis-admin$ vi gitosis.conf
    增加内容如下
    [group storeweb]
    members = javanew
    writable = storeweb
    查看git状态
    liuhongdi@lhdpc:/data/testgit/gitosis-admin$ git status
    位于分支 master
    您的分支与上游分支 'origin/master' 一致。
     
    尚未暂存以备提交的变更:
      (使用 "git add <文件>..." 更新要提交的内容)
      (使用 "git restore <文件>..." 丢弃工作区的改动)
            修改:     gitosis.conf
     
    修改尚未加入提交(使用 "git add" 和/或 "git commit -a”)
    提交
    liuhongdi@lhdpc:/data/testgit/gitosis-admin$ git add -A
    liuhongdi@lhdpc:/data/testgit/gitosis-admin$ git commit -m "增加storeweb项目"
    [master 2d33b46] 增加storeweb项目
    1 file changed, 3 insertions(+), 1 deletion(-)
    push到服务器
    liuhongdi@lhdpc:/data/testgit/gitosis-admin$ git push origin master 
    3,把storeweb项目push到服务器
    查看是否已设置remote
    liuhongdi@lhdpc:/data/vue/storeweb$ git remote -v
    liuhongdi@lhdpc:/data/vue/storeweb$
    添加remote
    liuhongdi@lhdpc:/data/vue/storeweb$ git remote add origin ssh://git@121.122.123.147:1888/storeweb.git
    查看效果
    liuhongdi@lhdpc:/data/vue/storeweb$ git remote -v
    origin  ssh://git@121.122.123.147:1888/storeweb.git (fetch)
    origin  ssh://git@121.122.123.147:1888/storeweb.git (push)
    push到服务器
    liuhongdi@lhdpc:/data/vue/storeweb$ git push origin master

    五,查看本地git版本:

    liuhongdi@lhdpc:/data/vue/storeweb$ git --version
    git version 2.30.2 
  • 相关阅读:
    弹出窗口失败 Debug Assertion Failed!
    颜色设置 OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 的用法
    启动项
    进程PK线程
    获取代码运行时间,获取当前系统时间,日期
    在WindowsPhone8中生成基于MVVM Light的LongListSelector拼音检索绑定
    微软认证考试Mcts70511 part1翻译_Part2_使用控件_ContentControl
    微软认证考试Mcts70511 part1翻译_Part1_考分分配
    ORA14452: attempt to create, alter or drop an index on temporary table already in use
    HPUX日常工作整理
  • 原文地址:https://www.cnblogs.com/architectforest/p/15293870.html
Copyright © 2020-2023  润新知