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

Copy file in commit to a new commit in another branch #4078

Open
KennethHoff opened this issue Nov 26, 2024 · 1 comment
Open

Copy file in commit to a new commit in another branch #4078

KennethHoff opened this issue Nov 26, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@KennethHoff
Copy link

Is your feature request related to a problem? Please describe.
I'm currently in the process of splitting this branch I'm working on into two branches; There were a lot of unrelated changes in it, so I wanted to create a new "Remove old code" branch. The commits I've made weren't particularly good so there are a lot of random files in random commits. I used the Copy/Paste commit feature to copy some of the earliest commits, but one of the commits contains a hodge-podge of random files of which I want one of them in the new branch.

Describe the solution you'd like
Pressing C in the "Diff files" view should move that file to the Clipboard, similar to how you can use C in the Commits view. Afterwards, pressing V over the Commits view in a different branch should spawn the commit-creation popup allowing you to create a commit containing only the copied file.

Describe alternatives you've considered
As a user, I could manually edit the commits in order to have a dedicated commit for this file and then copy that file, but that's a lot of addtional steps.

Additional context

@KennethHoff KennethHoff added the enhancement New feature or request label Nov 26, 2024
@stefanhaller
Copy link
Collaborator

This is what custom patches are for. In the Diff Files view, press space on the file you want to copy to add it to a custom patch, then press ctrl-p and pick "apply patch" to add it to your working copy. You'll then still have to commit it from there, but compared to your proposed solution this has the advantage that it also works on parts of a file's diff.

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