Reputation: 395
This is what happened:
git add
+ git commit -m "my message"
and git push
But after that, my local git showed the changes as commited/pushed and when I execute git status
, this is what I have:
On branch staging
nothing to commit, working tree clean
Is it possible to "undo" the procedure and move my code changes to a new branch, which will be merged to a protected branch via pull request later on?
Upvotes: 1
Views: 546
Reputation: 391604
To move your commits to a new branch, you can do the following:
Make sure you do not have any uncommitted changes before doing this, one of the steps below will do a hard reset, which will wipe out such changes
If in doubt, make a backup of your entire working folder, with the .git repository inside, to make sure you don't mess anything up
Make sure you have the feature branch that is protected checked out locally, at your latest commit, the one you didn't manage to push
Create a new branch:
git branch new-feature-branch
(note, this does not check out the new branch, so you're still on the previous feature branch, the one that is protected)
Reset the feature branch back to where the remote says it is
assuming your remote is origin:
git reset --hard origin/feature-branch-name
Check out and push your new branch
git checkout new-feature-branch
git push --set-upstream origin new-feature-branch
Go through the pull request process in gitlab or github
Upvotes: 2