Home Download Buy Blog Forum Support

Open files and switching git branches

Open files and switching git branches

Postby hubert on Wed Nov 14, 2012 6:31 am

Hi,

I was just wondering if anybody else had the problem and what they were doing about it:

When working on a project I frequently switch git branches (for example to quickly inspect work of someone else, or to fix a bug) and when I do so, I tend to have files open that don't exist in that other branch.

ST2 now shows those files as unsaved while on the other branch and every so often it happens that I accidentally save one of those files for which I then have to go back into the command line and rm it in order to be able to switch back again.

Is there a way to make ST2 save the open file configuration, then, when switching to another branch possibly restore previously open files (and close the other ones) and vice versa?

I was thinking of resorting to simply having 2 clones of my git repository but then I would have to create a new virtualhost and remember to use the right one when checking things. With one clone it works fine, just ST2 is a little annoying with regards to that.

Anyone having the same trouble? What are your solutions? Thanks!
hubert
 
Posts: 31
Joined: Mon Jan 09, 2012 12:12 pm

Re: Open files and switching git branches

Postby skuroda on Wed Nov 14, 2012 7:51 am

Hmm, that's an interesting problem. I haven't had that problem yet, but maybe I will take a shot at a plugin to solve that issue. Not 100% sure how it will work yet, but my thinking is leveraging "git diff --name-status <current_branch>..<branch_switching_to>" close and open the necessary files. I'm guessing you are leveraging the Git plugin for sublime, so assuming what I'm thinking works, I'm not quite sure how it will integrate.

Sorry though, no immediate solutions for you.
skuroda
 
Posts: 674
Joined: Fri Oct 05, 2012 8:11 am

Re: Open files and switching git branches

Postby phillip.koebbe on Wed Nov 14, 2012 12:24 pm

Related discussion: viewtopic.php?f=3&t=9695
-- Phillip

Code: Select all
while self.living? do
    mistake = Mistake.new
    self.learn_from!(mistake) unless mistake.fatal?
end
phillip.koebbe
 
Posts: 208
Joined: Tue Dec 20, 2011 4:58 pm

Re: Open files and switching git branches

Postby apc on Sat Jun 01, 2013 4:28 am

The problem does not seem to be restricted to files that are not in the branch you switch to. See: viewtopic.php?f=3&t=4302
apc
 
Posts: 1
Joined: Sun Aug 21, 2011 4:48 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 13 guests