Hi Michael,

On Wednesday, April 26, 2017 at 7:31:53 PM UTC+2, Michael Gersten wrote:
>
> So I'm having a "too much pulled" issue, that I'd like help with. 
>
> I'm working with this remote: 
>
> [remote "origin"] 
>         url = https://github.com/rg3/youtube-dl.git 
>         fetch = +refs/heads/*:refs/remotes/origin/* 
>
>
> I wanted to be able to get pull requests to test and play with, and I was 
> told to add this line: 
>
>         fetch = +refs/pull/*/head:refs/remotes/origin/pr/* 
>

By doing this you explicitly said you want *all* pull requests (notice the 
* signs in there). If you wanted to have a specific one updated each time 
you do plain `git fetch`, you may have done it like this instead:

(*1*) fetch = +refs/pull/12121/head:refs/remotes/origin/pr/12121
 
... (notice using specific pull request id, in this case 12121, instead of 
*).


Which worked -- I was able to say 
>   843  git fetch origin refs/pull/12121/head 
>

If you wanted to fetch like this, you don`t need the above mentioned 
.config edit, just that it fetches to FETCH_HEAD, you don`t get a branch 
automatically.

If you want to fetch into a branch, you can do it like this:

(*2*) git fetch origin pull/<PULL_REQUEST_ID>/head:<NEW_LOCAL_BRANCH_NAME>

You can even simulate the remote branch by doing something like this:

(*3*) git fetch origin pull/12121/head:refs/remotes/origin/pr/12121

... or if you edited .config as described in (*1*), you can just do `git 
fetch`, without additional parameters.

To create a local remote tracking branch out of it:

(*4*) git checkout -b pull/12121 --track origin/pr/12121

 

> No problem. 
>
> What was the problem? Doing an update. 
>
> keybounceMBP:youtube-dl michael$ git pull master 
> fatal: '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. 
>

Here, you are using `git pull` with a wrong parameter, providing it a 
branch name, where it`s expecting a remote name first (see git-pull[1] 
<https://git-scm.com/docs/git-pull>).


keybounceMBP:youtube-dl michael$ git pull 
> remote: Counting objects: 17909, done. 
> remote: Compressing objects: 100% (112/112), done. 
> remote: Total 17909 (delta 10124), reused 10079 (delta 10078), pack-reused 
> 7717 
> Receiving objects: 100% (17909/17909), 74.44 MiB | 3.01 MiB/s, done. 
> Resolving deltas: 100% (12988/12988), completed with 3257 local objects. 
> From https://github.com/rg3/youtube-dl 
>    629dc1892..b876a9cd7  gh-pages             -> origin/gh-pages 
>    a4d6cf970..3dc8b61b7  master               -> origin/master 
>  * [new ref]             refs/pull/0/head     -> origin/pr/0 
>  * [new ref]             refs/pull/100/head   -> origin/pr/100 
>  * [new ref]             refs/pull/10011/head -> origin/pr/10011 
>  * [new ref]             refs/pull/10012/head -> origin/pr/10012 
> ... 
>
> So, instead of updating master, like I thought, or just the one pull 
> request I had previously gotten (NB: those would be the only refs I had 
> from that github), I now have lots and lots of things I don't care about or 
> want. 
>

You explicitly said you want *all* the pull requests (as explained above, 
using the * sign), thus this is expected and correct behavior.


My first question is, if I just delete the files from 
> .git/refs/remotes/origin/pr/ that I don't want, will that result in git 
> cleaning up the unwanted branches? 
>

Yes, you can do that manually, or you can do something like this as well:

(*5*) git for-each-ref --format="%(refname:short)" 
refs/remotes/origin/pr/\* | xargs git branch -rD


My second question is: The only way I could manage to update master was: 
>
> keybounceMBP:youtube-dl michael$ git fetch origin master 
> From https://github.com/rg3/youtube-dl 
>  * branch                master     -> FETCH_HEAD 
> keybounceMBP:youtube-dl michael$ git checkout master 
> Switched to branch 'master' 
> Your branch is behind 'origin/master' by 12 commits, and can be 
> fast-forwarded. 
>   (use "git pull" to update your local branch) 
> keybounceMBP:youtube-dl michael$ git pull 
> Updating a4d6cf970..3dc8b61b7 
> Fast-forward 
>  .github/ISSUE_TEMPLATE.md         |   6 ++--- 
>
> ... 
>
> So, what is the proper/best usage of fetch/pull? At the moment, I'm 
> interested in these branches: 
> origin master 
> origin refs/pull/12121 
> gkoelln Dish 
>

For what you want, those commands you`ve shown above are correct.


And, while I did explicitly ask for pull request 12121, it did not show up 
> in my remotes -- 
> [branch "master"] 
>         remote = origin 
>         merge = refs/heads/master 
> [branch "Dish"] 
>         remote = gkoelln 
>         merge = refs/heads/Dish 
>

Where did you "explicitly ask for pull request 12121" remote tracking 
branch, in order for it to be shown here? I haven`t seen that command in 
your e-mail, so unless you accidentally omitted it, you didn`t actually ask 
for it... yet.


so what do I need to do to tell git that this is something I'm interested 
> in? 
>

To do that, and to have the local remote tracking branch appear here, you 
may use the commands (*3*), to fetch the remote pull request, and (*4*), to 
create and checkout a remote tracking branch, as mentioned above, having it 
shown alongside "master" and "Dish" you showed above, as expected.

Regards,
Buga

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to