Permalink
Browse files

Change directory before switching branches

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...
1 parent b1c5df4 commit b2934f1b300b1a0195ecda3884b63d64559a5f73 @timothyasp timothyasp committed Feb 14, 2013
Showing with 6 additions and 1 deletion.
  1. +6 −1 git.rb
View
@@ -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)

0 comments on commit b2934f1

Please sign in to comment.