worktree - switching branch without stash

2016-04-03 :: ( 1 minutes reading )

Some times you are working on some feature but then you need to check or fix something on some other branch. The normal way to do it is that we do:

  1. git stash
  2. switch to other branch
  3. commit changes
  4. swith to previous branch
  5. git stash pop

This can be complicated especially you have multiple stash. You can’t easily understand which stash belongs where.

After version 2.5.2 there is new command called git worktree

Basically it can create new directory which checkout different branch

example

$ git worktree add ../branch-temp some-branch
$ cd ../branch-temp

// hack
// finish

$ cd ../original-path
$ rm -rf ../branch-temp

// cleanup

$ git worktree prune

more detail about the command are available at https://git-scm.com/docs/git-worktree

comments powered by Disqus

Archives

English

  • My Desktop With i3, polybar, conky, and rofi
  • Convert Intellij Live Template to vscode Snippet
  • Why for-range behaves differently depending on the size of the element (A peek into go compiler optimization)
  • Testing go 1.5 cross compilation on raspberry pi
  • osx-push-to-talk App
  • Tracking origin of bugs with git bisect
  • Stubbing Time.Now() in golang
  • My account just got hacked by Romanian (Possibly)
  • berks upload core dump
  • Safely sharing credentials with PGP

Indonesia

  • Ruby Fiber apaan sih ?
  • Scale MongoDB dengan Sharding
  • Telepon murah ke Indonesia dengan voip

Today I Learned

  • Intellij as git diff and mergetool
  • Checksum a File From a URL
  • Global Gitignore File
  • View kubernetes secret
  • Push Only Current Branch
  • Convert PDF to Text Using OCR
  • Checkout Last Branch
  • Replacing Last Command and Execute It
  • Open Last Command in the Editor With Fc
  • Regex for Validating Password
Labs.Yulrizka.com
twitter github feed
    • Left Panel
    • No Panel
    • Right Panel
  • Home
  • EN
  • ID
  • Today I Learned

© Ahmy Yulrizka 2019. Made with hugo source