有没有办法将我当前的开发分支作为一个步骤合并到暂存分支?
Is there a way to merge my current dev branch to a staging branch as a step?
我在机器上安装了 git,但是当我尝试在 shell 脚本中 运行 "git fetch origin/staging" 时,我不断收到以下错误消息:
git fetch origin/staging
fatal: 'origin/staging' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
script returned exit code 128
我的下一个 shell 命令是
git checkout origin/staging
git merge dev
fatal: 'origin/staging' does not appear to be a git repository
注意origin/staging
指的是远程跟踪分支。错误消息告诉您 git fetch
需要远程名称。所以试试
git fetch origin
那你应该做
git checkout staging
它创建了一个名为 staging
的新本地分支,它指向与远程跟踪分支 origin/staging
相同的提交。那么你可以做
git merge dev
就像你一样。
git fetch
不期望 <branch>
作为第一个参数,而是 <remote>
,所以你可以
git fetch origin
(查看 doc 了解详情)
但是,您可以专门为远程上的分支获取,但您必须在远程上明确说明,否则您的分支将被假定为远程本身:
git fetch origin staging
(注意我们这里用的是分支本身的名称,不是 origin/staging
,是跟踪的remote-tracking分支的名称它在你的存储库中)
成功了!第一步检查暂存分支。第二步将dev合并到staging。最后一步将分期推送到原点。
stage('Merge') {
steps {
git branch: 'staging', credentialsId: 'a-long-id', url: 'https://test@bitbucket.org/project/myrepo.git'
sh 'git merge dev'
sh 'git push origin staging'
}
}
我在机器上安装了 git,但是当我尝试在 shell 脚本中 运行 "git fetch origin/staging" 时,我不断收到以下错误消息:
git fetch origin/staging
fatal: 'origin/staging' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
script returned exit code 128
我的下一个 shell 命令是
git checkout origin/staging
git merge dev
fatal: 'origin/staging' does not appear to be a git repository
注意origin/staging
指的是远程跟踪分支。错误消息告诉您 git fetch
需要远程名称。所以试试
git fetch origin
那你应该做
git checkout staging
它创建了一个名为 staging
的新本地分支,它指向与远程跟踪分支 origin/staging
相同的提交。那么你可以做
git merge dev
就像你一样。
git fetch
不期望 <branch>
作为第一个参数,而是 <remote>
,所以你可以
git fetch origin
(查看 doc 了解详情)
但是,您可以专门为远程上的分支获取,但您必须在远程上明确说明,否则您的分支将被假定为远程本身:
git fetch origin staging
(注意我们这里用的是分支本身的名称,不是 origin/staging
,是跟踪的remote-tracking分支的名称它在你的存储库中)
成功了!第一步检查暂存分支。第二步将dev合并到staging。最后一步将分期推送到原点。
stage('Merge') {
steps {
git branch: 'staging', credentialsId: 'a-long-id', url: 'https://test@bitbucket.org/project/myrepo.git'
sh 'git merge dev'
sh 'git push origin staging'
}
}