Daniel
Daniel

Reputation: 6842

A working directory for every branch

My typical workday involves reviewing other devs' code and fixing multiple bugs at once. Are there any methodologies to quickly checkout a branch without having to interrupt your work in the current branch?

I do this many times per day and frequently forget which step I'm on.

  1. git stash

  2. git checkout feature-b

  3. git pull

    ... make some commits, etc ...

  4. git push

  5. git checkout feature-a

  6. git stash pop

Edit: Multiple directories are cool, but I don't think it's necessarily the only way to solve this.

Upvotes: 2

Views: 456

Answers (2)

Joe Phillips
Joe Phillips

Reputation: 51150

I would:

  • Save all work
  • Make a Work In Progress commit
  • Switch branches

I don't trust stashes enough to save work in them. I might just save a local config setting or something that isn't critical.

Upvotes: 0

VonC
VonC

Reputation: 1325155

A better workflow would be to use the git worktree command, which allows you to checkout different branches (of the same repo cloned only once) in different folders.

That way, no more stash to do, only a pull in the right folder.
You current work in a given branch remains untouched, unmodified, while you are doing a review in another folder/branch.

Upvotes: 2

Related Questions