gitbutlerapp / gitbutler

The GitButler version control client, backed by Git, powered by Tauri/Rust/Svelte
https://gitbutler.com
Other
12.64k stars 500 forks source link

Support for partial commit and unsquashing #2626

Closed aeonik closed 1 month ago

aeonik commented 7 months ago

Hello, I think it might be a good idea to have support for "unsquashing commits" and moving individual hunks from a single commit to other commits, or branches.

Use Case: Just now I made a change to a config file, and a build tool also updated the version in this same config file. I want to split the change out.

Using the CLI to split the commit, I would do this:

  git add -p <file>.              # partial stage
  s                               # for each hunk

For splitting the hunk into a branch, I would do this:

  git checkout -b new-branch-name
  git reset HEAD^                 # if I already staged it
  git add -p
  s                               # for each hunk

Using Magit, splitting out the commit:

  M-x magit-status
  TAB                             # on the file diff
  s                               # per hunk
  e                               # when I need to refine it manually

Using Magit, to move hunks to a different branch:

  M-x magit-status
  TAB                             # on the file diff
  b c                             # new branch
  <same process as before>
  b b                             # as needed, switch branches

Regards, Aeonik

ericclemmons commented 7 months ago

I wonder if this why I'm running into issues separating 1 change amongst 3 of the same file:

https://github.com/gitbutlerapp/gitbutler/assets/15182/25f5dba6-012c-4d46-86ed-ddbded013844

krlvi commented 3 months ago

Hello! It took a while but this is now implemented in app versions 0.12+ (changelog) Scott also wrote an article here, summarizing how these changes work.

@aeonik let me know if these changes cover the use cases you had in mind

Caleb-T-Owens commented 1 month ago

We now support dragging files out of commits as well as commit files in git add -p fashion by clicking on specific hunks.

Feel free to open new issues if the behavior is not how you expect 👍