3 ms·
Maybe this already exists somewhere and I don't know about it ... Anyway, when working on feature branches I wanted a quick way to switch to master, pull, swit
by lelanthran 4y ago
Maybe this already exists somewhere and I don't know about it ...
Anyway, when working on feature branches I wanted a quick way to switch to master, pull, switch back and finally rebase.
So I made a little script (https://gist.github.com/lelanthran/6c9bd1125f89e7621364878d1b97a5fc https://gist.github.com/lelanthran/6c9bd1125f89e7621364878d1...) that pushes the current branch name onto a stack before switching to a new branch, and allows me to switch back to the topmost branch on the stack.
xgit master # Switch to master from current <really long branchname>
git pull
xgit pop # Switches back to <really long branchname>
git rebase master
I use this now very frequently; when I need to switch to branches I use `xgit <branch>`, because then I can switch back easily using `xgit pop`.
- switz 4y agoit’s not a stack, but you can toggle to the prior branch with `git checkout -` Or to move back N branches you can do: `git checkout @{-N}`
- warmuuh 4y agoYou can update a branch without checking it out: git pull origin master:master Still, two commands..
- nextlevelwizard 4y agog co master g fetch g rebase g co - g rebase - Where ’alias g=git’ and ’g config alias.co=checkout’