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

Worktree aliases #104

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

dabrown645
Copy link

I have started using worktrees on my projects and put together some basic aliases for entering worktree subcommands so I thought I would contribute them to this package.

I noticed after initial push that README.md didn't have my updates and doc/index.md did so this adds link for README.md to doc/index.md along with the other changes.

  I noticed after pushing up to github the README.md didn't have my
  updates so I linked to doc/index.md so there is only one source
  of truth
@joelparkerhenderson
Copy link
Member

joelparkerhenderson commented Oct 19, 2023

Great, thank you! Worktree is a super command for easy experimentation.

A few questions for you...

  1. I see wtd says "remove". Did you mean to create wtr meaning r instead of d? Or did you mean for the help text to say "delete" or "drop" instead of "remove"?

  2. What do you think about wtl for "list" (not "lock") because "list" is so common, and "lock" is typically not common? This is akin to git l for list, rather than git ls.

  3. What do you think about more? Such as wtlp for "worktree list --porcelin", and wtlv for "worktree list --verbose"?

  4. In an ideal setup you're correct about README.md commit. But there's a Chesterton's Fence problem. Git handles symlinks differently per version and depending on helper tools. For the time being, there need to be two sources of truth. Or possibly a precommit hook that copies one to the other and rewrites the links.

If you would like to fix up your merge request, that's great. Pull rebase (because there's a fix that came it just today for a bunch of quotations), then push any of the changes you want to do above. Or if you prefer to have me to do it, that's fine too; I'm so grateful for your code.

Thank you so much, again, for all your additions. These will be really useful for many people and teams. And I especially appreciate that your doing the doc, links, etc. that make it easier for people to use.

doc/git-wtu/index.md Outdated Show resolved Hide resolved
doc/git-wtp/index.md Outdated Show resolved Hide resolved
doc/git-wtls/index.md Outdated Show resolved Hide resolved
doc/git-wtl/index.md Outdated Show resolved Hide resolved
doc/git-wta/index.md Outdated Show resolved Hide resolved
gitalias.txt Outdated Show resolved Hide resolved
Co-authored-by: Lorenz Leutgeb <lorenz.leutgeb@gmail.com>
Co-authored-by: Lorenz Leutgeb <lorenz.leutgeb@gmail.com>
Co-authored-by: Lorenz Leutgeb <lorenz.leutgeb@gmail.com>
Co-authored-by: Lorenz Leutgeb <lorenz.leutgeb@gmail.com>
Co-authored-by: Lorenz Leutgeb <lorenz.leutgeb@gmail.com>
@dabrown645
Copy link
Author

Sorry it took me a while to get back I was on mini vacation with grand kids.

wtd was chosen for 'worktree remove' because worktree has a repair option which would conflict with wtr so I chose wtd for remova and it has same concept and doesn't conflict with wtr for worktree repair.

As you pointed out wtu is missing an assignment it should be wtu = worktree unlock do you want an other pull request with the correction

@joelparkerhenderson
Copy link
Member

Thanks for the new info. I believe that you're able to push a correction for wtu into this pull request, and also revert the README deletion, and then this PR is good to merge. (Or if you prefer, I can do all that for you)

Copy link
Member

@lorenzleutgeb lorenzleutgeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gitalias.txt in the base branch is outdated.

@@ -485,59 +513,59 @@
add-alias = "!f() { \
if [ $# != 3 ]; then \
echo \"Usage: git add-alias ( --local | --global ) <alias> <command>\"; \
echo \"Error: this command needs 3 arguments.\"; \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't forget to update your base branch, so that it is at or ahead of 95d5fda.

Copy link
Member

@lorenzleutgeb lorenzleutgeb Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and as of now it should be at or ahead of 12c40fc. There are conflicts to resolve now anyway.

Copy link
Member

@lorenzleutgeb lorenzleutgeb Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unresolved this conversation, as I do still see unexpected/unrelated changes in gitalias.txt even after @dabrown645's merge commit ca6abe3.

@joelparkerhenderson
Copy link
Member

If you prefer me to add the aliases for you, rather than trying to do this pull requests, let me know.

This is because this pull request is a bit more complex than a typical one would be, because the .gitconfig file is large, and there are significant changes happening this week, so your changes are being blocked by the newer changes. Happy to explain more if that could be helpful for you.

@dabrown645
Copy link
Author

I understand there is a lot going on with gitalias and if it is easier for you to add the wortree aliases then trying to do this pull request I am ok with that.

Have you thought about breaking gitalias up into 2 pieces that could be included one with the aliases and one with the workflow. This would make it the configuration cleaner if someone chooses a different workflow or no aliases for workflow. I have noticed some issues with my workflow and using worktrees that I am working through now.

@joelparkerhenderson
Copy link
Member

if it is easier for you to add the wortree aliases then trying to do this pull request I am ok with that.

Thank you. I'll proceed with this.

Have you thought about breaking gitalias up into 2 pieces

Yes. Some teams really like this approach because it's flexible. Other teams really dislike this approach because they have to track multiple files. What seems to satisfy both kinds of teams, in practice, is for them to use gitalias.txt as one big starter file, then write team-specific overrides in their own separate files.

I have noticed some issues with my workflow and using worktrees that I am working through now.

Can you say more about this?

@dabrown645
Copy link
Author

I have noticed some issues with my workflow and using worktrees that I am working through now.

Can you say more about this?

First let me confess I am not a git expert I am a retired system administrator and used get to keep some control the scripts that automated a lot of the work I did. I have worked with development teams and their various workflows but never quite settled on one for my stuff. I think my issues with worktrees is the way I set them up. I followed some guidance to manage directory chaos using bare repository (https://morgan.cugerone.com/blog/how-to-use-git-worktree-and-in-a-clean-way/).
The article identified on issue and fix when trying to fetch remote branches.

When I tried creating a pull for this changed I ran into anther problem . I cloned with the bare repository did wta main and changed into it to add remote tracking it didn't work. I figured out that if I went into the bare repo and add remote tracking it worked.

Right now I don't know if there are any other issues I will run into or if I need to make a change to the way I set up my clone.

@joelparkerhenderson
Copy link
Member

Good info and context, thank you.

Git worktrees and bare repos are great features. They do tend to make things more complex.

For example, in 100+ teams where I've used git, only 1 team is using worktrees and bare repos regularly. Nearly all the other teams do typical work on one branch, and use stash in the rare case it's needed (as the article you sent describes). A handful of teams prefer to do a "wip" commit, meaning "work in progress"; later on, when a teammate decides to work on that branch again, then the teammate amends the commit with more work and a better commit message, or does more commits then squashes.

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

Successfully merging this pull request may close these issues.

3 participants