TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

How I Use Git Worktrees

26 点作者 nalgeon10 个月前

8 条评论

francislavoie10 个月前
Re &quot;stash is bad&quot; comment, I agree, but only if you&#x27;re using git in CLI. If you use something like GitKraken, then you can visually see your stashes and it&#x27;s pretty obvious what they&#x27;re about. I find it easier to manage that way. But I definitely do the &quot;just do a WIP commit on current branch then switch away&quot; thing as well.<p>I&#x27;ve never used worktrees, but one thing I noticed from this post is that it adds an extra FS dir layer. This would break a few workflows at my company, we use relative paths to reference sibling git repos in certain situations (e.g. to run the server in one repo which servers a build sourced from the sibling frontend repo, etc). Knowing which worktree to use in that case wouldn&#x27;t really work, those scripts using relative paths would need somekind of input&#x2F;arg for the worktree name.
评论 #41075349 未加载
wvenable10 个月前
This is similar to how I use worktrees. I have a worktree for the master&#x2F;main branch; this is the current production branch. I have a worktree for test, which contains current branch deployed for testing. And I have worktree for doing new development.<p>If I&#x27;m doing new development and bug report comes in, I can just open the production project. I don&#x27;t need to stop what I&#x27;m doing in my development branch at all. I don&#x27;t have to worry about build artifacts or other details that come when you just switch branches in place. I also really dislike stashing.<p>I don&#x27;t know why they aren&#x27;t more popular.
评论 #41074965 未加载
Ivan9210 个月前
I am kind of curious to know how many people know and utilize git worktrees since it is fairly new (introduced in git v.2.28). I find it to be quite practical and your approach to git worktrees makes sense.
评论 #41075225 未加载
评论 #41074994 未加载
clemsen10 个月前
For anyone who wants to work on (non conflicting) changes at the same time, using a UI, I can recommend Gitbutler. Here you can check out multiple branches at the same time (e.g. do a development workflow at the same time as a bugfix). It is a little bit confusing at first, but I like it.<p><a href="https:&#x2F;&#x2F;gitbutler.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;gitbutler.com&#x2F;</a>
frizlab10 个月前
Interesting. This is <i>exactly</i> my workflow, except I have 3 worktrees instead of 5: r&#x2F;o remote, work and review.
评论 #41076590 未加载
vitaminCPP10 个月前
&gt; &quot;ggc utility&quot;<p>Does anybody know what this is? Google won&#x27;t help.
评论 #41084897 未加载
heyrikin10 个月前
Thanks for sharing!
snthpy10 个月前
Thanks for sharing:<p>``` TL;DR: consider using worktrees not as a replacement for branches, but as a means to manage concurrency in your tasks. My level of concurrency is:<p>main for looking at the pristine code,<p>work for looking at my code,<p>review for looking at someone else’s code,<p>fuzz for my computer to look at my code,<p>scratch for everything else!<p>```