Skip to content

Add a button to clone branches #2895

Closed

Description

@szmarczak

To clone a branch manually:

  1. Go to the branch you want to clone.
  2. Click Edit on any file. Do not make any changes.
  3. Make sure you have selected this:

image

  1. Open Chrome Dev Tools.
  2. Inspect the Propose file change button.
  3. Remove the disabled attribute.
  4. Click Propose file change.

🎉 In other words, it makes a spin off from your branch and makes an empty commit (I don't know of any solution that wouldn't create an empty commit).

Activity

  1. fregante commented on Mar 15, 2020

    @fregante
    Member

    You can already clone it:

    1. Visit branch
    2. Open branch selector
    3. Type new branch name
    4. Click create
  2. yakov116 commented on Mar 15, 2020

    @yakov116
    Member

    @fregante wow I never knew that!!

  3. fregante commented on Mar 15, 2020

    @fregante
    Member

    If this “Duplicate” button is added to the Branches page, it can replace this feature request: #2500, also because renaming isn’t a safe operation

  4. yakov116 commented on Mar 15, 2020

    @yakov116
    Member

    @fregante curious why is renaming not a safe option?

  5. fregante commented on Mar 15, 2020

    @fregante
    Member

    Explained in #2500: it doesn’t move PRs

  6. yakov116 commented on Mar 15, 2020

    @yakov116
    Member
    query GetBranchInfo {
      repository(owner: "yakov116", name: "TestR") {
        id
        ref(qualifiedName: "Test") {
          target {
            oid
          }
        }
      }
    }
    
    mutation CreateBrach {
      createRef(input: {repositoryId: "MDEwOlJlcG9zaXRvcnkyNDQyMTU0NzY=", oid: "a1a98b7b5460f87a31cc6e12699a6e71e2390988", name: "refs/head/yes"}) {
        clientMutationId
        ref {
          id
        }
      }
    }

    @fregante like this? Or do you want to hack the drop down menu?

  7. fregante commented on Mar 15, 2020

    @fregante
    Member

    If v3 only requires a fetch we can use that instead of v4, we don't get about its body anyway

  8. fregante commented on Mar 15, 2020

    @fregante
    Member

    On https://github.com/sindresorhus/refined-github/branches

    1. Add icon-only button next to each delete button
    2. On click, ask name via prompt ("cancel" or empty name will cancel the action)
    3. Change the icon to "Creating..."
    4. await api.v3(...)
    5. Update UI (I think just location.reload())
  9. yakov116 commented on Mar 15, 2020

    @yakov116
    Member

    If v3 only requires a fetch we can use that instead of v4, we don't get about its body anyway

    They both require 2 calls. One to get the commit the brach is up to. And one to create the branch.

    Creating the branch via V3 is simple.

  10. fregante commented on Mar 15, 2020

    @fregante
    Member

    Ugh. The GraphQL schema for this is awful. Private IDs should not be exposed at all.

    Two v3 calls are fine since it's a specific user action.

    This is not exactly a high-priority feature though.

  11. yakov116 commented on Mar 15, 2020

    @yakov116
    Member

    await api.v3(repos/${user}/${repo}/git/refs/heads);
    Gives all the branches
    Only make the call after the user clicks?
    The benefit of using v3 for the branches is that we get all of them at once
    To create is
    POST /repos/:owner/:repo/git/refs
    OR
    use V4 and only get that branch info, then use v3 to create the branch

  12. fregante commented on Mar 15, 2020

    @fregante
    Member

    The last OR sounds good. V4 GET, V3 POST

  13. yakov116 commented on Mar 15, 2020

    @yakov116
    Member

    V3 I can get the direct info

  14. fregante commented on Mar 15, 2020

    @fregante
    Member

    What’s direct info? V4 also has the commit info, it’s just what we need. V4 requests are light, v3 GET requests aren’t

  15. yakov116 commented on Mar 15, 2020

    @yakov116
    Member

    await api.v3(repos/${user}/${repo}/git/refs/heads/${branchName!});

  16. yakov116 commented on Mar 15, 2020

    @yakov116
    Member

    I have every thing done I am having a hard time making a post

  17. fregante commented on Mar 15, 2020

    @fregante
    Member

    Only make the call after the user clicks?

    Why do you keep asking this? I said it before. Is this going to be like your last PR of me saying the same thing 4 different ways before the code was updated?

  18. yakov116 commented on Mar 15, 2020

    @yakov116
    Member

    No no. I know I know. Your right.

    It was a mistake that line got in there

  19. fregante commented on Mar 19, 2020

    @fregante
    Member

    @szmarczak why do you need to clone a branch?

  20. yakov116 commented on Mar 19, 2020

    @yakov116
    Member

    Owh... I thought you closed the issue

    image

  21. szmarczak commented on Mar 19, 2020

    @szmarczak
    Author

    Sometimes I need to rebase a PR I'm working on (e.g. start from scratch with a different implementation) and I don't want to lose the current progress.

  22. fregante commented on Mar 19, 2020

    @fregante
    Member

    Commits aren't lost, you just need to save the commit hash

  23. szmarczak commented on Mar 19, 2020

    @szmarczak
    Author

    IKR, but I'm lazy to do so :(

  24. szmarczak commented on Mar 19, 2020

    @szmarczak
    Author

    I think that the clone-branch feature would be a safer option :)

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions