我找不到能够推动除master以外的任何分支中的更改的理由。我的意思是,我有一个master分支,是通过将代码推送到gitlab创建的。然后,任何尝试将更改推送到主分支的尝试都将失败。不过,我将我的master分支复制到另一个名为dev的分支,并且可以在其上推送更改。为简单起见,让我把谷歌搜索一段时间后的所有事情都放在上面:
C:\dev\test>git fetch --all
Fetching origin
C:\dev\test>git reset --hard origin/master
HEAD is now at 64031f0 just created by generator
... some changes via my editor ....
C:\dev\test>git commit -a -m "changed project name"
[master 5abf2f2] changed project name
1 file changed, 5 insertions(+), 5 deletions(-)
C:\dev\test>git push -u origin/master
fatal: 'origin/master' 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.
C:\dev\test>git push
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 365 bytes | 365.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Error: This is the master branch, and the commit has no merge request
remote: 64031f03f1723e3399ad467dbbb536942fe144f0 5abf2f29e0ced51289d1fcd684b1510acd354764 refs/heads/master
To ssh://gitlab.mycomp.net:2222/myportfolio/mycomp-app-sf-just-test.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'ssh://git@gitlab.mycomp.net:2222/myportfolio/mycomp-app-sf-just-test.git'
C:\dev\test>git push -u origin master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 365 bytes | 365.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Error: This is the master branch, and the commit has no merge request
remote: 64031f03f1723e3399ad467dbbb536942fe144f0 5abf2f29e0ced51289d1fcd684b1510acd354764 refs/heads/master
To ssh://gitlab.mycomp.net:2222/myportfolio/mycomp-app-sf-just-test.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'ssh://git@gitlab.mycomp.net:2222/myportfolio/mycomp-app-sf-just-test.git'
简而言之,我看到的大多数答案都告诉您使用git push -u或取消保护分支。现在我的gitlab项目分支不受保护,如您所见,我正在使用-u
答案 0 :(得分:4)
GitLab似乎不允许您直接将其推入master
。这是一种常见的做法。相反,您应该从功能分支创建一个合并请求到主请求。当您在GitLab UI中接受合并请求时,它将自动创建合并提交并移动master
分支。
答案 1 :(得分:3)
您的问题可能与permissions与Gitlab的工作方式有关。
如果您在我的链接文档列表中单击,您会看到:
<?php if ( is_page( '123' ) ) { ?>/* change number */
<?php } elseif ( is_page( '321' ) ) { ?> /* change to different number */
<?php
$catPost = get_posts(array('post_type' => 'your_post_type', 'post_status' => array('publish', 'future'),'tax_query' => array(array('taxonomy' => 'your_cpt_categories', 'field' => 'slug', 'terms' => 'your-category-slug')))); //change these to suit your registered custom post type, taxonomies, post status, etc.
foreach ($catPost as $post) {
setup_postdata($post);
$ids[] = get_the_ID();
}
//we now have an array of ids from that category, so then
$idList = implode(",", $ids); //turn the array into a comma delimited list
$meta_key = 'your_meta_key';//set this to your custom field meta key
$allmiles = $wpdb->get_var($wpdb->prepare("
SELECT sum(meta_value)
FROM $wpdb->postmeta
WHERE meta_key = %s
AND post_id in (" . $idList . ")", $meta_key));
echo '<p>Total miles is ' . $allmiles . '</p>';
?>
<?php } else { ?>
<?php the_content(); ?> /* or do other stuff */
<?php } ?>
只有拥有 Maintainer (在 11.0 之前是Master)和 Owner 权限的人才能使用。
找不到能够推动除master以外的任何分支中的更改的原因
这是因为默认情况下仅主服务器受保护。因此,您需要提升的权限才能直接在该分支上进行推送。
答案 2 :(得分:2)
这里的问题是默认情况下master分支是受保护的一个。 如果要使用存储库设置->受保护分支下的“取消保护”按钮,可以更改该设置。 另外,您也可以更改merge的分支可访问性设置,也可以更改为维护者,开发人员级别。 请参阅屏幕以获取更多详细信息。