Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pushing changes to a pull request URL? #821

Closed
eterps opened this issue Feb 24, 2015 · 8 comments
Closed

Pushing changes to a pull request URL? #821

eterps opened this issue Feb 24, 2015 · 8 comments

Comments

@eterps
Copy link

eterps commented Feb 24, 2015

You can check out a PR using:

$ hub checkout https://github.com/defunkt/hub/pull/73

When you make a change and commit that change, what do you do to push it to the PR?

Because just doing "git push" gives a message like this:

fatal: The upstream branch of your current branch does not match
the name of your current branch. To push to the upstream branch
on the remote, use

git push myproject HEAD:bar-baz

To push to the branch of the same name on the remote, use

git push myproject foo-bar-baz
@mislav
Copy link
Owner

mislav commented Feb 25, 2015

Yes, you will probably not be able to use just git push for a branch created this way. You need to tell explicitly where you want to push:

git push origin HEAD:my-branch-name

I know that this could be friendlier. Is the PR that you're checking out originating from the same repo or from a fork? If it's same-repo, then we could ensure that the local branch you're checking out to is the same name as the remote branch which is the head for the PR. Then, git push would simply work because the branches have matching names (see push.default section of git help config)

@eterps
Copy link
Author

eterps commented Feb 25, 2015

It's the same repo, ensuring that that the local branch is the same name as the remote branch would be an awesome improvement.

@eterps
Copy link
Author

eterps commented Nov 27, 2015

Is there a way to hub checkout a PR url without changing the name of the branch?

@mislav
Copy link
Owner

mislav commented Nov 27, 2015

No, hub still auto-generates the name of the checked-out branch so this is still not push-friendly.

I'll try to get this fixed for the next release so that same-repo PRs are easier to handle.

@tlvince
Copy link

tlvince commented Apr 25, 2016

Sorry for the "+1 comment", but this would be a very welcome addition.

My usual workflow is something like:

git push --tags --set-upstream origin branch

On subsequent pushes, simply git push will do.

Checking out a PR with hub creates a branch in the form [org]-[branch], so I'm forced to use something like following each time I want to update the PR:

git push [org]-[branch]:[branch]

Perhaps if origin contains org ([email protected]:[org]), the [org]- prefix can be omitted?

@mislav
Copy link
Owner

mislav commented Apr 26, 2016

@tlvince My idea for hub checkout <PR-URL> is that it should use the API to determine the context of the branch that you're checking out. If it's from the same repo, or from a fork that you have push access to, it will checkout a new branch and set up upstream tracking so git push should work without problems. If it's a fork that you don't have write access to (most open source forks), the branch will be checked out like right now: with auto-generated name, and without upstream configuration. It makes no sense to git push a branch from a repo you don't have write access to, anyway.

Let me know if that makes sense.

@sideshowbarker
Copy link

Now that the GitHub default for PRs is to allow pushes from upstream maintainers I bet a lot more people than before now want “it just works” for pushes from hub checkout <PR-URL> branches.

@sideshowbarker
Copy link

Workaround for now:

git config --global push.default upstream
git config --global [email protected]:.pushInsteadOf git://github.com/

With those settings a git push (with no args needed) in a hub checkout <PR-URL> branch will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants