-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Automatically add the upstream
remote when cloning a fork
#1977
base: master
Are you sure you want to change the base?
Conversation
if err != nil { | ||
ui.Errorln(output) | ||
} | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it should do a git fetch
for the added remote at this point? The normal case for doing a git clone
fetches the full history for the cloned repo; since we're basically cloning two repos at once here, maybe we should do fetch so we have both repos' history.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice that we're doing git remote add -f
. The extra flag automatically initiates a fetch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha. Missed that.
I like it! I'm a little confused by the |
Thanks for weighing in! I wasn't sure that my approach was the best solution. Primarily, I was just trying to avoid the |
Example: $ hub clone my-fork > origin: git://github.com/MYUSER/my-fork.git > upstream: git://github.com/OWNER/original-project.git $ hub clone --origin=upstream my-fork > (no origin remote) > upstream: git://github.com/OWNER/original-project.git
96e4614
to
7dd2e96
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. this looks great
What's with the holdup on a merge? |
@Kampfkarren The PR is ready, but I wanted to hold off until I can ensure (by adding tests) that other commands (e.g. |
Regarding I also agree 100% with @apjanke regarding remote naming:
Further, since many people have Have you considered something like this:
|
This was the main convention for as long as hub existed, but I feel the community has outgrown that convention. GitHub's own help docs now suggest a triangular git workflow where the canonical remote is called "upstream" and your own fork called "origin". I want to adopt this in hub because it would help with scripting: it's way easier for everyone if Of course, no convention will ever handle everyone's use-case. Hub doesn't and will not try to support different popular git workflows out there; it will only handle the one we (GitHub) generally recommend and believe in. |
@mislav can you revive this PR, this would be very useful |
Ref. #348
Fixes #811
/cc @apjanke