title: Can I rebase a Git branch without modifying my working copy?
body: <p>Suppose I have my "master" branch checked out. I've committed some production changes to "master", and now I want to rebase my "experimental" branch onto the latest master. But, I want to do this without modifying any files in my working copy. Essentially, I want all the magic to happen inside the .git directory, without touching the working copy.</p>
  
  <p>If not for the "don't modify my working copy" requirement, this would just be a matter of doing:</p>
  
  <pre><code># current branch is master
  git checkout experimental
  git rebase master
  git checkout master
  </code></pre>
  
  <p>My real problem is that this modifies timestamps in my working copy, even though I'm ending by checking out the exact same content I started with. As soon as I run "git checkout experimental", any files that contain changes in the experimental branch will get their mtime set to the current time -- and so will any files that were changed in master since the last time I rebased experimental. Because the mtimes have changed, things like build tools get the idea that there's work they need to do again, even though, by the time I'm done, the files' contents haven't actually changed. (In my case, it's that if a project file's timestamp changes, Visual Studio thinks it needs to spend a lot of time unloading and reloading the project.) I want to avoid that.</p>
  
  <p><strong>Is there a way to do all of the above in one step, without ever modifying anything in the working copy</strong> <em>(assuming there are no conflicts during the rebase)<strong></em>?</strong></p>
  
  <p>(If there <em>are</em> conflicts, my preference would be to show the error and then abort the entire operation, without ever modifying any timestamps. But that's just my preference, not a hard requirement -- I don't know what all is possible.)</p>
  
  <p>Of course I can write a script to capture the mtimes, run git, and then reset the mtimes; but it seems likely that Git would already have a way to do things like rebase without bothering the working copy, since the rebase is really about the deltas, not the files' actual contents.</p>