git - Accidentally created new branch with existing name -
i'm starting use branches git, , created yesterday branch foo
, pushed remote. today wanted work on home, after running pull typed without thinking git checkout -b foo
.
i know shouldn't have added -b
option, because got message switched new branch 'foo'
, none of code wrote yesterday shows in folders figure accidentally messed branch names.
i tried renaming branch using git branch -m foo bar
hoping deal local branch , deduplicate branch names, alas git checkout foo
issued message error: pathspec 'foo' did not match file(s) known git.
how can retrieve branch created yesterday?
the problem ran created new branch did not track remote branch wanted.
i think "right" way correct set branch track intended remote branch:
git checkout foo git branch -u origin/foo
after doing can move local branch current commit of remote branch
git reset origin/foo
you can add , commit local changes. pull , push usual.
(an alternative reset
rebase
on origin/foo
instead, not recommend beginner)
Comments
Post a Comment