Skip to content

Commit

Permalink
Change directory before switching branches
Browse files Browse the repository at this point in the history
Running submodule update --init will error unless you are in your projects
TLD. Uses `git rev-parse --show-toplevel` to get the projects TLD.
  • Loading branch information
timothyasp committed Feb 14, 2013
1 parent b1c5df4 commit b2934f1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion git.rb
Expand Up @@ -142,9 +142,14 @@ def self.stashes
end

def self.switch_branch(branch)
# capture only the path, not the newline
basedir = `git rev-parse --show-toplevel`.split("\n").first

# change directory to base dir
Dir.chdir(basedir)

self.run_safe("git checkout \"#{branch}\"")
self.run_safe("git submodule --quiet update --init --recursive")

self.run_safe("git clean -ffd") if ARGV.include?('--clean')

self.show_stashes_saved_on(branch)
Expand Down

0 comments on commit b2934f1

Please sign in to comment.