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

Create a new branch without checkout. #3453

Open
yam-liu opened this issue Mar 29, 2024 · 1 comment
Open

Create a new branch without checkout. #3453

yam-liu opened this issue Mar 29, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@yam-liu
Copy link

yam-liu commented Mar 29, 2024

Is your feature request related to a problem? Please describe.
Yes, I use a backed branch for a top commit (some local config change) which should not be pushed to remote.

When I make some changes and amend the previous commit, I want to push the changes but not the top commit, I will use the backed branch (e.g. tmp) to track.
delete the tmp and create a new branch at the top commit. But at this time, I don't want to checkout the branch, just for backing up.

Describe the solution you'd like
create a branch without checkout or force create a same-name branch.

Describe alternatives you've considered
push the branch from any commit of the branch, not only the top. something like
git push origin the_branch~3:the_branch. I know I may lose some commit if do the operation, but a tip can be shown before the aciton.

Additional context
.

@yam-liu yam-liu added the enhancement New feature or request label Mar 29, 2024
@stefanhaller
Copy link
Collaborator

For creating a branch without checking it out, you could create a custom command similar to this one:

  - key: "<whatever>"
    description: 'Create a new branch without checking it out'
    command: "git branch {{index .PromptResponses 0}} {{.SelectedLocalCommit.Sha}}"
    context: 'commits'
    prompts:
      - type: 'input'
        title: 'Branch Name'
        initialValue: ''

For pushing a command that is not the head of your branch, a custom command like this one could be helpful.

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

No branches or pull requests

2 participants