【问题标题】:how to request pull request from a particular remote in git?如何从 git 中的特定远程请求拉取请求?
【发布时间】:2014-01-25 23:22:06
【问题描述】:

这是我的 git 配置文件的外观:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = false
[remote "origin"]
        url = git@github.com:XXXXXXX/training.test.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
[remote "upstream"]
        url = https://github.com/YYYYYYY/training.test.git
        fetch = +refs/heads/*:refs/remotes/upstream/*

remote“origin”指向我的github账号 remote "upstream" 指向一个不同的 github 帐户,与我分叉到我的帐户不同。

Q1:所以每次我做一个git pull,它都会从我的remote(这是“原点”)得到pull。 我将如何处理git pullremote upstream

Q2:我 commit and push 对我的存储库的任何更改,必须通知其他用户“YYYYY”以获取拉取请求。我将如何实现这一目标?

【问题讨论】:

    标签: git github git-push git-pull git-remote


    【解决方案1】:
    1. git pull remoterepo remotebranch[:localbranch](例如git pull upstream foo:bargit pull pustream foo

      或者git checkout --track upstream/remotebranch,如果你的本地仓库没有这样一个名为remotebranch的分支

      您可以使用git branch -r 显示远程分支。

    2. 你可以使用github webhook

    【讨论】:

    • 这不起作用:git pull upstream/master fatal: 'upstream/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.
    • Is 表示您的 upstream 存储库中没有分支名称 master。那么你想拉上游的哪个分支。例如git pull upstream/foo master
    • 所以尝试使用git branch -r 来查看远程分支。:)
    • 当我执行git branch -r 时,我看到upstream/master,但git pull upstream/master 失败
    • 对不起.. 不是git pull upstream/master,而是git pull upstream master
    【解决方案2】:
    1. git pull upstream branchname,可以通过git branch -a获取远程分支的完整列表
    2. 您可以在 git 存储库中配置挂钩以在推送后通知项目中的所有成员,请参阅 herehere

    ps。关于Q2,可以找similar question,提供其他解决方案

    【讨论】:

    • 这不起作用:我收到此错误:`您要求从远程“上游”拉取,但未指定分支。因为这不是您当前分支的默认配置远程,所以您必须在命令行上指定一个分支。
    • @user1988876 那么你应该使用git pull upstream master,你可以使用git branch -a来查看你可以从哪里拉取的完整列表
    猜你喜欢
    • 2018-12-01
    • 2014-04-30
    • 2011-12-31
    • 2019-09-09
    • 1970-01-01
    • 1970-01-01
    • 2017-04-11
    • 2017-08-04
    • 1970-01-01
    相关资源
    最近更新 更多