title: How do I recover/resynchronise after someone pushes a rebase or a reset to a published branch?
body: <p>We have all heard that one should never rebase published work, that it’s dangerous, etc. However, I have not seen any recipes posted for how to deal with the situation in case a rebase <em>is</em> published.</p>
  
  <p>Now, do note that this is only really feasible if the repository is only cloned by a known (and preferably small) group of people, so that whoever pushes the rebase or reset can notify everyone else that they will need to pay attention next time they fetch(!).</p>
  
  <p>One obvious solution that I have seen will work if you have no local commits on <code>foo</code> and it gets rebased:</p>
  
  <pre><code>git fetch
  git checkout foo
  git reset --hard origin/foo
  </code></pre>
  
  <p>This will simply throw away the local state of <code>foo</code> in favour of its history as per the remote repository.</p>
  
  <p>But how does one deal with the situation if one has committed substantial local changes on that branch?</p>