git worktree

How, what and why to code in BYOND.
Post Reply
User avatar
JJRcop
Joined: Wed Apr 23, 2014 1:52 am
Byond Username: JJRcop
Github Username: JJRcop

git worktree

Post by JJRcop » #222391

Have two+ working trees that both hook into the same repo!

So I just now found this out but git since 2.5 (july 2015 :sad:) has a command that allows you to just make a new working tree and that tree will be linked to the master repo you used the command in.

(From root of current working tree)

Code: Select all

git worktree add ../tgstation2
This will checkout whatever branch you currently have checked out (by creating a new one based off it) into ../tgstation2 and now you can work on two branches at the same time instead of having to git stash or git commit your changes then reapply them back into the working tree. You can of course do this as many times as you want (providing different directory names silly), and it allows you to work on two or more branches literally at the same time with two dreammaker instances etc, and two versions of the game you can compile and use independently etc etc.

And also it's all linked to the same repo with the same refs (except HEAD and a few others i think). The commands you call are not being called on a cloned repo that is synced with the main repo, but the main repo itself, no hacky workaround methods used.

More info here: https://git-scm.com/docs/git-worktree


I really am very happy I found this and wish I found it way earlier.
I lurk quite often...
User avatar
kevinz000
Joined: Fri Nov 14, 2014 8:41 am
Byond Username: Kevinz000
Github Username: kevinz000
Location: Dorm Room 3

Re: git worktree

Post by kevinz000 » #226126

I'm a GUIscrub, does this work with git for windows?
User avatar
JJRcop
Joined: Wed Apr 23, 2014 1:52 am
Byond Username: JJRcop
Github Username: JJRcop

Re: git worktree

Post by JJRcop » #227439

kevinz000 wrote:I'm a GUIscrub, does this work with git for windows?
If you're talking about the GUI part of git for windows, then no, git-gui does not provide an interface to git worktrees. You must click "repository" at the top left and then click "Git Bash" to pop open a command line so you can use this feature.
I lurk quite often...
Post Reply

Who is online

Users browsing this forum: No registered users