首页
技术
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

handazao

养家糊口
首页
技术
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • Docker使用

  • 数据库相关

  • Java相关

  • Linux学习

  • 工具

  • vue3

  • Git

    • pre-commit
    • commit-msg
    • pre-push
      • 1.在项目.git\hooks目录里面编写pre-push文件
  • 技术
  • Git
handazao
2024-08-07
目录

pre-push

# 1.在项目.git\hooks目录里面编写pre-push文件

#!/bin/sh

echo "-----------------------------当前操作是: pre-push-----------------------------"

# 第二个远程仓库名称
GITLAB_REMOTE_NAME="GITLAB_REMOTE"
GITLAB_REMOTE_URL="GITLAB_REMOTE_URL"

# 配置第二个远程仓库(如果尚未配置)
if ! git remote | grep -q "$GITLAB_REMOTE_NAME"; then
    echo "Configuring $GITLAB_REMOTE_NAME remote..."
    git remote add $GITLAB_REMOTE_NAME $GITLAB_REMOTE_URL
fi

# 获取当前分支名称
current_branch=$(git rev-parse --abbrev-ref HEAD)

# 输出当前分支名称
echo "当前分支是: $current_branch"

# 推送代码
git push $GITLAB_REMOTE_NAME $current_branch:$current_branch --force

if [ $? -ne 0 ]; then
  echo "git push failed......."
  exit 1
fi

# 允许推送
exit 0


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#git
上次更新: 2024/08/07, 16:19:09
commit-msg

← commit-msg

最近更新
01
commit-msg
08-07
02
pre-commit
08-07
03
vue3核心技术
06-27
更多文章>
Theme by Vdoing | Copyright © 2020-2024 handazao | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式