Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit b2934f1b300b1a0195ecda3884b63d64559a5f73 1 parent b1c5df4
Tim Asp timothyasp authored
Showing with 6 additions and 1 deletion.
  1. +6 −1 git.rb
7 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)
Please sign in to comment.
Something went wrong with that request. Please try again.