How do I move my recent commits on master to a new branch, and reset master to before those commits were made? e.g. From this:
master A – B – C – D – E
To this:
newbranch C – D – E
/
master A – B
WARNING: If you have to store uncommitted edits to your stash before you do this, git stash. When you move the stashed unconmitted editings with GitHub stash pop, it will look like this if you want to move it to a new branch (git checkout existingbranch ggitgit merge merge branch) and an old branch branch will remove all changes.\n\nWith the first command: git branch newbranch. If you want to merge your commits to an existing branch before executing – HEAD3 (see Moving to the previous branch) — if you don\’t re-enhanced your changes, it\’s the place where you\’re going to apply for the branching and rolling back — [against [brain] branch-to-apped branch, \’read-outout-in-ex-tailtail-s-are-not-doo-\” branch), .\n\nBut don\’t worry about how many commits to return.Rather than HEAD3, you can provide the hash of the commit (or the reference like origin/master) you want to \”revert back\” on the master (/current) branch, e.g: git reset –hard a1b2c3d4.\n\nNote: Note that you will be \”losing\” commits from the master branch, but don\’t worry, you\’ll be looking at git log -n4 which will show the history of newbranch (after the 4 step sequence of commands above), but will still be able to check for the fact that they were deleted from master (and that the branch that was checked out at the time of its execution, i.e. Master: Reset current HEAD to the specified state) – — will not show any checkouts on master, although they\’re push pushpushed.\n\nWARNING: With Git version 2.0 and later, if you later git rebase the new branch upon the original (master) branch, you may need an explicit –no-fork-point option during the ebase to avoid losing the carried-over commits. Having branch.autosetupre base base always set is more likely. See John Mellor for details.