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

Pull request checkout with no 'leftovers' #1206

Open
rcorre opened this issue Jul 7, 2016 · 11 comments
Open

Pull request checkout with no 'leftovers' #1206

rcorre opened this issue Jul 7, 2016 · 11 comments
Labels

Comments

@rcorre
Copy link

rcorre commented Jul 7, 2016

I often checkout a pull request as a one-time thing. I want to take a look at the code and run it, but afterwards I'll switch back to my own branches and don't want a new remote or branch hanging around. It would be nice to have --no-remote and --no-branch flags for hub checkout.

I would expect --no-remote to do:

git fetch <remote-url>
git branch user-branchname FETCH_HEAD
git checkout user-branchname

With --no-branch it would be:

git fetch <remote-url>
git checkout FETCH_HEAD

Does this sound useful? I'd be happy to take a stab at it (I'd like to learn some go).

@mislav mislav added the feature label Jul 11, 2016
@mislav
Copy link
Owner

mislav commented Jul 11, 2016

That's not a bad idea. I definitely already have a plan to change the checkout command to never add a remote, since those can pile up over time and are not very useful. The branch is another topic, though. By default a branch will definitely be created, but I'll consider your --no-branch option to avoid creating a branch and put you to detached head instead.

Since I plan to refactor checkout significantly, you don't have to make a contribution right now, since it will likely conflict with the other changes. So don't worry about making the PR right now! But If you'd like to learn some Go, there are definitely other issues in the projects that need attention… 😉

@rcorre
Copy link
Author

rcorre commented Jul 11, 2016

Thanks, sounds good to me.

@mcornella
Copy link

mcornella commented Jul 16, 2016

+1.

The official github doc uses the command

git fetch origin pull/ID/head:BRANCHNAME

which avoids the git branch call.

Thanks for submitting this!

@rcorre
Copy link
Author

rcorre commented Jul 17, 2016

Oh, that's clever, and a good workkaround in the meanwhile. Thanks!

@mcornella
Copy link

Yay thanks! 🎉

@mislav
Copy link
Owner

mislav commented Aug 20, 2016

Mind that the new implementation still leaves a branch around. But, most importantly, it doesn't create any git remotes anymore.

@mcornella
Copy link

That's exactly what I'd expect as a user so thanks!

@rcorre
Copy link
Author

rcorre commented Aug 21, 2016

Thanks! Not having a remote is nice, but is there any chance of adding a no-branch option to fetch to FETCH_HEAD?

@mislav
Copy link
Owner

mislav commented Aug 21, 2016

@rcorre That shouldn't be too hard to add. Please take a look at the current checkout implementation and see if you can find your way around adding such a feature. If it's too confusing, let me know!

@mislav mislav reopened this Aug 21, 2016
@rcorre
Copy link
Author

rcorre commented Aug 22, 2016

I'll give it a shot, thanks!

rcorre added a commit to rcorre/hub that referenced this issue Aug 31, 2016
The flag is parsed manually, which seems like it should not be
necessary based on other command implementations. I need to find out
why registering the flag with the command isn't working.

Currently this only works if the pull request is from a different repo.

Resolves mislav#1206.
@andrejserafim
Copy link

This is quite old, but perhaps it will be useful to someone. A work around is to checkout always to the same branch and remove it before the checkout, so there's always 1 branch with the last code review.

#!/usr/bin/env bash

git checkout master &&
git branch -D review &&
hub pr checkout $1 review &&
git pull upstream master

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

No branches or pull requests

4 participants