Skip to content

Git和jenkins

git

Gitlab

image-20220103182439449

gitlab安装

shell
1.导入镜像:docker load -i /vspn30/soft/docker/images/gitlab.tar
2.创建目录

image-20210128155007633

image-20210128155031953

shell
3.运行
docker-compose up -d
4.访问:http://192.168.1.252:6080

git推送代码

shell
//推送代码,在gitlab上创建然后拉到本地
git clone http://192.168.1.252:6080/root/vspn30-jdjc.git

image-20210329151336504

本地

image-20210329151410605

上传提交git

进入目录

image-20210329152100617

shell
//添加代码
git add .
//提交
git commit -m 'add vspn30-jdjc'
//提交远程仓库
git push origin master

image-20210329152758872

分支创建提交

sh
$ git checkout -b "20210330"
$ git add .
$ git commit -m "20210330"
$ git push
//查看分支
$ git branch
//删除本地分支
git branch -d dev20181018

image-20210330102344450

更改IP

sh
docker exec -it   gitlab /bin/bash
[root@localhost config]# cd /opt/gitlab/embedded/service/gitlab-rails/config 
cd /var/opt/gitlab/gitlab-rails/etc/
//gitlab-ctl reconfigure
gitlab-ctl restart

image-20220103193725632

image-20220103193735498

image-20220103193934322

image-20220103195124944

sh
docker exec -it  gitlab /bin/bash

image-20220419145834060

image-20220419145523000

sh
gitlab-ctl reconfigure
gitlab-ctl restart

Git拉取分支

sh
git clone -b web https://github.com/hailangsun/wiki.git
git clone -b web https://github.com/hailangsun/wiki.git "./"

服务器安装git

sh
yum install git
git --version

centos7 git记住密码

sh
git config --global credential.helper store

git合并分支

远程分支合并到当前分支

checkout 当前分支

image-20230516145633642

找到远程分支dev分支

image-20230516145712081

合并到了当前分支,然后把合并的代码提交到自己的远程分支上,

远程git新建了分支,拉取时候如图

image-20230516145820799

image-20230516145950879

gitlab-docker 安装方法

bash
docker pull gitlab/gitlab-ce

image-20230704201747592

docker-compose.yml

bash
version: '3'
services:
  gitlab:
    restart: always
    image: gitlab/gitlab-ce:latest
    container_name: gitlab
    hostname: '192.168.124.19'
    environment:
      TZ: 'Asia/Shanghai'
      GITLAB_OMNIBUS_CONFIG: |
        gitlab_rails['time_zone'] = 'Asia/Shanghai'
        external_url 'http://192.168.124.19:6080'
        gitlab_rails['gitlab_shell_ssh_port'] = 6022
    ports:
      - '6081:443'
      - '6080:6080'
      - '6022:22'
    volumes:
        - /docker/gitlab/data/config:/etc/gitlab
        - /docker/gitlab/data/logs:/var/log/gitlab 
        - /docker/gitlab/data/data:/var/opt/gitlab


docker-compose up -d

http://192.168.124.19:6080

进入容器内找到初始密码

bash
docker exec -it gitlab /bin/bash
cat /etc/gitlab/initial_root_password

image-20230704204217387

bash
root/wang123456789

idea提交方式

新版idea需要去掉勾选

image-20230704210556429

学习使我快乐吗?