Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
git-tools
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
common-tools
git-tools
Commits
0af7e879
Commit
0af7e879
authored
Jul 31, 2018
by
huasheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加新工具
parents
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
127 additions
and
0 deletions
+127
-0
git_merge_branch.sh
git_merge_branch.sh
+101
-0
git_submit_merge_request.sh
git_submit_merge_request.sh
+26
-0
No files found.
git_merge_branch.sh
0 → 100644
View file @
0af7e879
#!/usr/bin/env bash
#
target_branch
=
$1
need_push_after_update
=
$2
#if [ -z "$target_branch" ] || [ "$target_branch" != "develop" -a "$target_branch" != "master" ]
if
[
-z
"
$target_branch
"
]
then
target_branch
=
"develop"
fi
current_branch
=
$(
git branch |
grep
'*'
|
awk
'{print $2}'
)
git pull origin
$current_branch
if
[
$?
-ne
0
]
then
echo
"***********************************"
echo
"当前分支 "
$current_branch
" 拉取失败"
echo
"***********************************"
exit
else
echo
"==================================="
echo
"当前分支 "
$current_branch
" 拉取成功"
echo
"==================================="
fi
git push origin
$current_branch
if
[
$?
-ne
0
]
then
echo
"***********************************"
echo
"当前分支 "
$current_branch
" 推送失败"
echo
"***********************************"
exit
else
echo
"==================================="
echo
"当前分支 "
$current_branch
" 推送成功"
echo
"==================================="
fi
git checkout
$target_branch
if
[
$?
-ne
0
]
then
echo
"**********************************"
echo
"目标分支 "
$target_branch
" 切换失败"
echo
"**********************************"
exit
else
echo
"==================================="
echo
"成功切换到目标分支 "
$target_branch
echo
"==================================="
fi
git pull origin
$target_branch
if
[
$?
-ne
0
]
then
echo
"**********************************"
echo
"目标分支 "
$target_branch
" 拉取失败"
echo
"**********************************"
exit
else
echo
"==================================="
echo
"目标分支 "
$target_branch
" 拉取成功"
echo
"==================================="
fi
git merge
$current_branch
if
[
$?
-ne
0
]
then
echo
"********"
echo
"合并失败"
echo
"********"
exit
else
echo
"========"
echo
"合并成功"
echo
"========"
fi
git checkout
$current_branch
if
[
$need_push_after_update
-eq
1
]
then
git push origin
$target_branch
if
[
$?
-ne
0
]
then
echo
"**********************************"
echo
"目标分支 "
$target_branch
" 推送失败"
echo
"**********************************"
else
echo
"=================================="
echo
"目标分支 "
$target_branch
" 推送成功"
echo
"=================================="
fi
fi
echo
"===================================="
echo
"向目标分支 "
$target_branch
" 合并完成"
echo
"===================================="
git_submit_merge_request.sh
0 → 100644
View file @
0af7e879
#!/usr/bin/env bash
#
merge_request_comment
=
$1
if
[
-z
"
$merge_request_comment
"
]
then
echo
"请对此次Merge Request操作编写相关描述
\n
"
exit
fi
current_branch
=
$(
git branch |
grep
'*'
|
awk
'{print $2}'
)
merge_temp_branch
=
$current_branch
"_merge"
git checkout master
&&
git pull origin master
&&
git checkout
-b
$merge_temp_branch
&&
git merge
--squash
$current_branch
&&
git commit
-m
$merge_request_comment
&&
git push origin
$merge_temp_branch
&&
git checkout
$current_branch
&&
git branch
-D
$merge_temp_branch
if
[
$?
-ne
0
]
then
echo
"***************************"
echo
"合并失败,请处理后自行处理"
echo
"***************************"
exit
else
echo
"===================================="
echo
"合并成功,请移步GitLab平台继续操作~"
echo
"===================================="
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment