![]() ![]() The harder case is that the other branch already exists: let's say it's br in the first graph above. If not, then simply make the new branch here (where master is now) and slide master back down to before c: % git branch newbranch Does that other branch already exist or not? So I can think of two main scenarios here. So I regret that c and d were made on master I wish they had been on some other branch. Let's start with a two-branch situation: % git log -oneline -all -graph You can move a branch, attaching it to any commit you like, with git reset. ![]() Though I am interested to hear solutions for both scenarios (this one, and one where I had other valid commits). So obviously I'm a bit new to git and I'm sure this has got to be a duplicate question, but maybe I am just having trouble identifying which existing questions are the duplicates with confidence.Īlso I tagged vs 20 because I use both and welcome any answers that explain how to do this through the IDE in either of those versions in additions to how to accomplish this in a shell. It's very possible I've run across the exact answer I need, but didn't realize it because I wasn't 100% if the scenario was the same as mine. I've done some searching and the answers I've found primarily focus on the first case I mentioned where changes weren't committed. or I want to be able to restore them (as changes, but not as a commit, obviously). And when I checkout the branch I want, I want my changes to be there. I just want the commit to go away as if it never happened. in particular I don't want to have to push two commits (one with the changes, and one that reverts the changes). I want my local branch to be as though I never made any changes. How do I effectively accomplish the same thing if I've already committed locally (but not pushed to remote)? Normally if I make changes in a branch and realize I meant to do it in a different branch, then I can simply stash the changes and then checkout the branch I want. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |