gh icon indicating copy to clipboard operation
gh copied to clipboard

gh pr 1 does not setup tracking branch

Open maxandersen opened this issue 10 years ago • 4 comments

I would expect gh pr 1 to make a branch which would allow git pull to run.

Instead you get:

There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=<remote>/<branch> pr-60

maxandersen avatar Mar 31 '14 08:03 maxandersen

Also, comparing to hub.io it would be nice if gh would automatically pull to get latest updates for a PR.

i.e. hub co https://github.com/jbosstools/jbosstools-website/pull/65 will do the following:

A) if branch not already created, created one using the name of the actual remote branch not the pr number

B) if branch already there run git fetch

this means hub co hub co https://github.com/jbosstools/jbosstools-website/pull/65 you will always have the latest/greatest for the PR.

With gh pr 65 you must manually run setup tracking branch AND run git fetch/pull.

would be great if it just did that for you.

maxandersen avatar Mar 31 '14 12:03 maxandersen

@maxandersen This sounds like a cool feature!

I was going down this route to solve this: https://gist.github.com/piscisaureus/3342247#gistcomment-580127

But after further thought, it might make more sense to add an --update flag.

So in effect gh pr 1 -u would remove the pr-1 branch if it exists locally and then create a brand new branch pr-1 with the latest pr updates.

Thoughts?

protoEvangelion avatar Nov 17 '17 21:11 protoEvangelion

you mean gh pr 1 would do as I suggested, but in addition you would do a --update flag to allow you to force it in no matter if there already is one ? I would call that --force instead.

btw. 3 years ago since I created that bug - if it gets added I might be able to not depend on hub that much :)

maxandersen avatar Nov 17 '17 23:11 maxandersen

Yes that is exactly what I was thinking.

What about doing --pull instead to pull latest changes so we can alias to gh pr 1 -p because aliasing --update and --force would conflict with other aliases.

You do git pull after all when you are updating local to latest PR commits right?

protoEvangelion avatar Nov 18 '17 00:11 protoEvangelion