通过 gitlab(或 git)合并分支的最快方法?
Fastest way to merge branches via gitlab (or git)?
我有一个开发分支和一个生产分支。我将更改从我的开发服务器推送到远程 gitlab 安装。然后我登录到 gitlab GUI 并执行合并请求(这非常耗时)。然后我从我的生产服务器 "git pull origin production"。
合并请求步骤需要很长时间才能完成。有没有更快的方法来做到这一点?我可以制作一个 bash/shell 脚本来将开发合并到生产中并使用一个命令拉下更新吗?如果是这样,这个合并请求是什么命令 运行?
我每天提出几次合并请求。任何能加快我所拥有的过程的东西都会很棒。
您无需通过 UI 即可合并更改 - 这是 Git 的核心功能之一。假设您有两个分支(development
和 production
),下面是合并更改的方式:
# Check out development branch
git checkout development
# Make changes, commit...
...
# Optional: Push development changes to the remote
git push origin development
# Check out production branch
git checkout production
# Merge the changes from the development branch
git merge development
# Push the changes to the remote
git push origin production
# Check out the development branch again
git checkout development
现在登录生产服务器并将更改拉到那里。
您当然可以将上述 checkout/merge/push 步骤放入脚本中 - 这很常见。
有一些方法可以在发生变化时自动拉取变化。这里有几个链接供您使用:
- Git: auto pull from repository?
- https://johnflynn.me/autodeploy-your-gitlab-projects/
希望它能帮助那些希望通过命令将你的分支合并到你的父分支的人
git checkout planedtoMergeToThisBranch
Git 合并 developedBranchNeedToMerge -> (开发)
Git 状态
git 推送原点 planedtoMergeToThisBranch
我有一个开发分支和一个生产分支。我将更改从我的开发服务器推送到远程 gitlab 安装。然后我登录到 gitlab GUI 并执行合并请求(这非常耗时)。然后我从我的生产服务器 "git pull origin production"。
合并请求步骤需要很长时间才能完成。有没有更快的方法来做到这一点?我可以制作一个 bash/shell 脚本来将开发合并到生产中并使用一个命令拉下更新吗?如果是这样,这个合并请求是什么命令 运行?
我每天提出几次合并请求。任何能加快我所拥有的过程的东西都会很棒。
您无需通过 UI 即可合并更改 - 这是 Git 的核心功能之一。假设您有两个分支(development
和 production
),下面是合并更改的方式:
# Check out development branch
git checkout development
# Make changes, commit...
...
# Optional: Push development changes to the remote
git push origin development
# Check out production branch
git checkout production
# Merge the changes from the development branch
git merge development
# Push the changes to the remote
git push origin production
# Check out the development branch again
git checkout development
现在登录生产服务器并将更改拉到那里。
您当然可以将上述 checkout/merge/push 步骤放入脚本中 - 这很常见。
有一些方法可以在发生变化时自动拉取变化。这里有几个链接供您使用:
- Git: auto pull from repository?
- https://johnflynn.me/autodeploy-your-gitlab-projects/
希望它能帮助那些希望通过命令将你的分支合并到你的父分支的人
git checkout planedtoMergeToThisBranch
Git 合并 developedBranchNeedToMerge -> (开发)
Git 状态
git 推送原点 planedtoMergeToThisBranch