git jenkins 基本部署之git远程仓库

1.git远程仓库如何使用?

实战一、如何将本地仓库与远程Gitee进行关联?
        1.注册gitee
        2.创建一个远程仓库?
        3.配置使用远程仓库
            3.1) Git 全局设置:
                git config --global user.name "oldxx"
                git config --global user.email "[email protected]"
            3.2) 将本地已有的git的仓库与远程关联
                cd existing_git_repo
                git remote add origin https://gitee.com/oldboy_xxx/rainbow.git
            3.3) 本地仓库代码推送至远程仓库?  (确保本地的所有资源已提交至本地仓库)
                git push -u origin master
            3.4) 推送不同的分支?
                git checkout dev
                git push -u origin dev
            3.5) 推送tag?
                git push -u origin --tags        #推送本地所有的tag
                git push -u origin v1.1         #指定推送某个本地的tag

实战二、将https方式修改为ssh密钥访问通讯?
        1.删除与远程https仓库的关联?
        [root@gitlab demo]# git remote remove origin
        [root@gitlab demo]# git remote -v

        2.添加新的关联?-->SSH方式
        [root@gitlab demo]# git remote add origin [email protected]:oldboy_xxx/rainbow.git
        [root@gitlab demo]# git remote -v
        origin    [email protected]:oldboy_xxx/rainbow.git (fetch)
        origin    [email protected]:oldboy_xxx/rainbow.git (push)
        
        3.在本地机器上生成一个密钥对,然后将公钥放入远程仓库?
        [root@gitlab demo]# ssh-keygen
        [root@gitlab demo]# cat ~/.ssh/id_rsa.pub        #复制public公钥内容
        
            找个右上角用户-->设置-->SSH公钥-->添加Key

实战二、如果现在开发的这个项目有小伙伴想加入进来怎么办?
             Linux
             MacOS
             ssh-keygen
             yum install git -y
             Windows?
            1.下载安装一个git软件  
                http://192.168.0.128/git/Git-2.10.0-64-bit.exe
                https://gitforwindows.org/
            2.打开 Git Bash工具
            3.使用git bash 工具 创建ssh密钥对
                ssh-keygen
            4.克隆项目
                $ git clone [email protected]:oldboy_oldxu/rainbow.git

实战三、新加入的小伙伴提交了内容,其他成员看不见怎么办?
            
            1.登录开发B--->WIndows 修改代码进行变更操作:
                touch README
                git add .
                git commit -m "Windows push README"
                git push origin master
            2.登录开发A--->Linux
                git pull origin master    #获取到开发B提交的代码

猜你喜欢

转载自www.cnblogs.com/oldsjf/p/11734481.html