How can I create a new branch before last 3 commits and move last 3 commits into the new branch? From :
a -> b ->c -> d-> e -> f (master)
To:
a-> b->c(master)
\
d-> e-> -> f(new_branch)
How can I create a new branch before last 3 commits and move last 3 commits into the new branch? From :
a -> b ->c -> d-> e -> f (master)
To:
a-> b->c(master)
\
d-> e-> -> f(new_branch)
If you're the sole owner of the repo, without the need to preserve a shared history with coworkers :
From your master
branch currently pointing at f
:
# create your new branch
git branch new_branch
# reset master where it should
git reset --hard c
# then push the rewritten version of master to gitlab (assuming "origin" here)
git push -f origin master
If, in the other hand, you're sharing this repo, breaking master
's history is probably to be avoided (discuss it with your team).