diff --git a/src/git.js b/src/git.js index 6ad74e31..af332dd3 100644 --- a/src/git.js +++ b/src/git.js @@ -965,7 +965,6 @@ GitEngine.prototype.checkoutStarter = function() { } this.forceBranch(args[0], args[1]); this.checkout(args[0]); - return; } @@ -1056,6 +1055,11 @@ GitEngine.prototype.branchStarter = function() { }; GitEngine.prototype.forceBranch = function(branchName, where) { + // if branchname doesn't exist... + if (!this.refs[branchName]) { + this.branch(branchName, where); + } + var branch = this.resolveID(branchName); if (branch.get('type') !== 'branch') { throw new GitError({ @@ -1064,6 +1068,7 @@ GitEngine.prototype.forceBranch = function(branchName, where) { } var whereCommit = this.getCommitFromRef(where); + this.setTargetLocation(branch, whereCommit); }; diff --git a/todo.txt b/todo.txt index b448c360..d358ca85 100644 --- a/todo.txt +++ b/todo.txt @@ -26,16 +26,3 @@ Big Bugs to fix: ~~~~~~~~~~ -yeah forces moving it to the commit you indicate -which is impossible as far as I can tell, short of detaching, deleting the branch, and doing branch [name] [commit] -(detach in case that's the branch you're currently on) -checkout -B [name] [commit] is equivalent to branch -f [name] [commit] and then checkout [name] -tl;dr "branch" is to "checkout -b" as "branch -f" is to "checkout -B" - -seems like "branch -f [name] [commit]" does the following: -git checkout --detach # in case you're on [name] -git branch -D [name] # delete -git branch [name] [commit] # move to given commit -git checkout [name] # switch back - -