Murmele / Gittyup

Understand your Git history!
https://murmele.github.io/Gittyup
MIT License
1.37k stars 107 forks source link

Support for git worktree #716

Open vzam opened 3 months ago

vzam commented 3 months ago

Gittyup is great but it does not fit a workflow including git worktree very well. It would be great to see such a feature implemented.

Murmele commented 3 months ago

Hi,

can you explain more about it?

vzam commented 3 months ago

Sure, I can explain how it benefits myself. In my work, I am often interrupted by bugs, PR reviews and things that pop up with a higher priority and before I was using worktrees I had several copies of the repository to work on, such that I wouldn't have to create tons of WIP commits or stash the changes before changing to a different branch and topic. Worktree basically helps doing that, it is integrated into git and it allows creating these copies of the repository on the fly, to work on a topic that comes up and be closed after the work was finished. It makes context switching much easier and allows to quickly jump into some code to look at with the colleagues. Compared to the approach of creating copies of the repository by hand, it shares the .git data and therefore to update all worktrees, you have to do only one fetch, you have the same .git configuration for all worktrees and you can quickly create and destroy those copies as necessary. The feature is documented here.

jensenr30 commented 3 months ago

@vzam I don't use git worktree myself, but I know some people really like it for the reasons you mentioned.

As a user of git worktree, can you provide sketches, diagrams, or descriptions of how Gittyup might be modified/extended to accommodate users of the worktree workflow?

vzam commented 3 months ago

I will work something out and follow up with it, I need to familiarize myself better with the feature in git itself.

vzam commented 3 months ago

@jensenr30 I think it makes most sense to first implement the basic functionality of switching worktrees and improve from there, so here are my thoughts:

1. Listing and Selecting Worktrees

git worktree list

List details of each worktree. The main worktree is listed first, followed by each of the linked worktrees. The output details include whether the worktree is bare, the revision currently checked out, the branch currently checked out (or "detached HEAD" if none), "locked" if the worktree is locked, "prunable" if the worktree can be pruned by the prune command.

Is that something that you can work with? After this is done, the next iteration could allow adding and removing worktrees.