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

Gracefully handle branch not having an upstream #90

Closed
sindresorhus opened this issue Sep 9, 2016 · 18 comments · Fixed by #321
Closed

Gracefully handle branch not having an upstream #90

sindresorhus opened this issue Sep 9, 2016 · 18 comments · Fixed by #321
Labels
enhancement 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt help wanted

Comments

@sindresorhus
Copy link
Owner

sindresorhus commented Sep 9, 2016

Issuehunt badges

~/dev/boxen tmp
❯ np patch --any-branch              
 ✔ Prerequisite check
 ❯ Git
   ✔ Check local working tree
   ✖ Check remote history
   Cleanup
   Installing dependencies
   Running tests
   Bumping version
   Publishing package
   Pushing tags

Command failed: git rev-list --count --left-only @{u}...HEAD
fatal: no upstream configured for branch 'tmp'

The above should not fail. The task should just be marked as skipped.

itaisteinherz earned $60.00 by resolving this issue!

@DylanPiercey
Copy link

@sindresorhus you could also default upstream to master.

git branch --set-upstream-to=origin/master master

@SamVerschueren
Copy link
Collaborator

@sindresorhus What happens if you push the changes to git without upstream? Does it work?

@sindresorhus
Copy link
Owner Author

@SamVerschueren No:

❯ git push
fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using

    git remote add <name> <url>

and then push using the remote name

    git push <name>

@sindresorhus
Copy link
Owner Author

@DylanPiercey I don't want to default to master. Let's say I have a local repo with no upstream, that I want to publish to a private npm account.

@SamVerschueren
Copy link
Collaborator

@sindresorhus So this means that the git push should also be skipped?

@sindresorhus
Copy link
Owner Author

Hmm, yeah. Maybe this is too much of an edge-case?

@SamVerschueren
Copy link
Collaborator

Let's say I have a local repo with no upstream, that I want to publish to a private npm account.

If that is your use case and this would fix it, don't see any problem of adding that check.

@jamestalmage
Copy link
Contributor

IMO, if we do this, we should guard against accidental use in some way.

I can totally see myself cranking out a quick small module and forgetting to setup the GH repo.

We could either:

  1. require the --force flag be used (or similar).
  2. only allow it for scoped packages (which would cover the private npm use case).

@gmcdev
Copy link

gmcdev commented Dec 14, 2017

Did any resolution come out of this?

@franciscop
Copy link

franciscop commented Feb 20, 2018

I am facing the same issue while trying to push from my branch plugins to a prerelease 1.0.0-alpha.1:

✔ Prerequisite check
 ❯ Git
   ✔ Check local working tree
   ✖ Check remote history
     → fatal: no upstream configured for branch 'plugins'

I do have a master and use that for the stable versions, while I am using the branches for prereleases. This way any big bug can be fixed easily and quickly from master (master is always clean and production ready), while I can experiment in my branch and publish minor versions for testing. But unfortunately with this bug I cannot use np, is there any workaround?

Using:

np --any-branch

@franciscop
Copy link

Hopefully I didn't break anything, but this was fixed on my case with:

git branch --set-upstream-to origin/plugins

Since I am pushing from the local branch plugins I think this makes sense.

@IssueHuntBot
Copy link

@issuehuntfest has funded $60.00 to this issue. See it on IssueHunt

@Norris1z
Copy link

@sindresorhus how about a --no-push flag to skip git push?

@itaisteinherz
Copy link
Collaborator

itaisteinherz commented Jan 5, 2019

Another way of handling this could be to prompt the user, asking whether they'd prefer to skip the push step or enter a branch name that would later be used for pushing.

@sindresorhus
Copy link
Owner Author

@Norris1z Adding a new flag should be the last option. We don't add flags lightly. Better to find a way to handle it automatically.

@sindresorhus
Copy link
Owner Author

Another way of handling this could be to prompt the user, asking whether they'd prefer to skip the push step or enter a branch name that would later be used for pushing.

I don't think prompting is worth it here. Not having an upstream might be intentional. I think skipping is better. If the user really wants to push, they should just set an upstream.

@IssueHuntBot
Copy link

@itaisteinherz has submitted a pull request. See it on IssueHunt

@IssueHuntBot
Copy link

@sindresorhus has rewarded $54.00 to @itaisteinherz. See it on IssueHunt

  • 💰 Total deposit: $60.00
  • 🎉 Repository reward(0%): $0.00
  • 🔧 Service fee(10%): $6.00

@issuehunt-oss issuehunt-oss bot added the 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt label May 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants