mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 00:40:07 +02:00
makes branch now
This commit is contained in:
parent
338259de12
commit
eeff8da035
2 changed files with 6 additions and 14 deletions
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
13
todo.txt
13
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
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue