![]() I’ll make a change in master, then create a new branch for doing some work. In the following example I’m going to create a new git repo. I’ll leave that up to the reader to decide. Note: as you’ll see, although this workflow is pretty cool, you could argue that git stash is just plain simpler and easier for a human mind to reason about. This is different to manually creating a new directory and git cloning your repo down, because with the worktree model the two sub directories are aware of each other. It does this by creating a new directory for you with a copy of your git repository that is synced between the two directories where they are stored. Git offers a feature referred to as a worktree, and what it does is allow you to have multiple branches running at the same time. This is where I was recently introduced to a concept in git referred to as a ‘worktree’ (thanks Kiran). Oh, and then you have to think about whether you actually want to use apply, which leaves the stashed changes in the stack, or if you meant to actually pop the stashed content ( git stash pop so it’s properly removed from the stack. Note: for the life of me I wish I could remember the syntax but it just eludes me every time. it’s git stash apply where n is the index you want to apply.) OK so not that tragic considering git stash list will indicate the branch on which the stash was taken (which helps), but I do then need to Google what the syntax is for popping a specific stash (e.g. ![]() Ultimately, when I’m done with my urgent task and ready to go back to my other branch, I then have to sift through my stash to find the relevant one I want to pop. This is a fairly straightforward workflow, but there is a mild annoyance which is that I happen to git stash a lot and I find when jumping over to a new branch to do some urgent work that I might end up git stash‘ing a few more times along the way. Typically you would need to first git stash anything you were working on (as it’s unlikely to be in a state where it can be committed), and then you’d have to leave your current branch to create a new branch from master and thus begin working on your new urgent task. ![]() There are times where you might be working from a particular git branch and need to quickly jump over to a different branch to do some urgent work. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |