On Mon, 09 Nov 2015 10:01:56 +0000 [email protected] (Phillip Lord) wrote:
> I've been using git-new-workdir and am finding it very useful, but am > finding one problem. How do I update a working directory created with > git-new-workdir if the branch it is one is changed in the main > directory. > > For example, say I have: > > ~/src/my-repo > > ~/src/my-repo-branch/master > ~/src/my-repo-branch/feature-branch > > where "master" and "feature-branch" are git-new-workdir'd branches > pointing to ~/src/my-repo. Now I pull to "~/src/my-repo" so it updates > say master (or feature-branch). In ~/src/my-repo-branch/master running > git log will show the latest commits to master, but the working > directory will be out of date. > > Is it possible to get this workdir up to date? Yes, there are several. The basic thing to understand is that `git-new-workdir` creates a separate HEAD ref in the new work tree's .git directory. Now recall how the whole thing works. If the HEAD in the original work tree is not detached (true in most cases) then it's a symbolic ref meaning it does point to a named branch rather than directly to a commit (using its SHA-1 name). Say, if you have the branch "master" checked out, HEAD contains the name of that branch. So, what then happens when you commit in your original work tree or perform `git pull` which updates the same branch? Among other things, the contents of the index and the work tree itself are updated. That is, the branch pointer points to that new commit, the index contains its contents and the work tree mirrors that. The difference with your other work tree having that branch checked out is that while the HEAD still points to the same branch, the branch pointer points to the new commit but the index and the work tree contain the stale data. So, the first thing to consider is doing `git reset --mixed` or `git reset --hard` BUT MAKE SURE first that you understand the implications of "--hard". The second thing to consider is the sequence of `git read-tree HEAD` and `git checkout-index`. Consider reading [1] to get full understanding of how the data pointed to by HEAD, contained in the index and in the work tree relate to each other. 1. https://git-scm.com/blog/2011/07/11/reset.html -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
