What command should I run if I want to keep my new work that I did on master? I accidentally forgot to open a new branch for this last segment of work that I did and I don't want to lose it by going back to origin/master. My SourceTree
Asked
Active
Viewed 527 times
1 Answers
2
If you started out as below:
O - O - 0 - C
\ \__ *master*
|
origin/master
You need to branch
git branch <branchname>
O - O - 0 - C
\ \__ *master*, branchname
|
origin/master
Now reset the master to origin/master
git reset --hard origin/master
O - O - 0 - C
\ \__ branchname
|
origin/master, *master*
If you would like be on the new branch
git checkout branchname
O - O - 0 - C
\ \__ *branchname*
|
origin/master, master
Libin Varghese
- 1,283
- 11
- 19
-
This will leave her new work on master and update
to point at the updates from origin/master – Haldean Brown Feb 27 '17 at 23:30 -
@HaldeanBrown: Notice I did not do a `git checkout -b`, but just a `git branch`. This make the current HEAD (master) also be referred as branchname. – Libin Varghese Feb 27 '17 at 23:34
-
Oh, my mistake. Sorry! – Haldean Brown Feb 28 '17 at 00:09