File content in Sublime does not change on Git branch change

If a file is open in Sublime text 2, and then branch is switched which has changes to the file in the terminal, the file contents are not updated in the Sublime text 2 until the editor is selected by clicking on it.

How to auto-magically change it?

  • What does “*.jpg binary -delta” do in the .gitattributes file?
  • Cloud9 IDE git setup
  • Using git merge, how can I merge a bugfix into multiple long-term branches?
  • How to do a pull request in GitHub with only the latest commit in the master branch of my forked repository
  • How can I deploy a WordPress site with Git without committing WP core?
  • git pull error “The requested URL returned error: 503 while accessing”
  • How to find local git branches that have been deleted from master
  • git clean: What does “Would not remove” mean?
  • How can I set up the working directory and the local repository on different drives?
  • Is there a way to make git auto generate a version number file for a --version option?
  • Get the path where git alias was run from
  • Why Restrict Branch Deletion (Git)?
  • 3 Solutions collect form web for “File content in Sublime does not change on Git branch change”

    Sublime Text does not have any built-in way to do this. Though perhaps a Sublime Text plugin could do it by combining the file refresher plugin in the forum thread with a Python equivalent to watchr.

    This Sublime Forum thread asks how to make a file in a different tab update automatically, given that Sublime Text is already frontmost. The asker couldn’t find a way to make Sublime Text do that, but as a workaround, wrote a plugin that lets them hit a hotkey to reload all open tabs.

    You could try to solve this with the same principle, by making a system-wide hotkey to switch to ST2 and back. You could implement the hotkey with AutoHotkey for Windows or Quicksilver or Keyboard Maestro for Mac. It’s not as good as automatic updating, but it’s the next best thing. You could hit the hotkey every time you expect the file to have changed.

    You could even use a tool like watchr to monitor for changes in the files you plan to edit, and automatically triggers an AutoHotkey script or AppleScript that switches to Sublime Text and back when a file is updated. It would be even better to dispense with the GUI scripting and using Sublime Text’s Python interface to reload the view without switching to it, but I don’t know if Sublime Text allows you to run Python in the app from a program outside the app.

    I had the same issue. Go to the git tab above and manually change the branch. that should revert the files back to any branch you want. The git tab above will work without typing anything into the terminal and will update with these git changes from sublime automatically.

    This just works in Sublime Text 2 and 3 on Mac.

    Git Baby is a git and github fan, let's start git clone.