Temporarily merged a branch into our development branch, want to undo

Viewed 25

so i seem to have created some git headaches for myself, wondering if someone's experience could help. I'll try explain clearly:

  • I have a development branch, which auto-builds onto our staging server
  • I have another branch feature/a - it has work in it that extends beyond development
  • I wanted to get feature/a temporarily onto our staging server, so did it the only way that is currently possible - i merged it into development
  • I then reset HEAD on my local machine for development, to a previous commit I had made of development, and it has been working well locally
  • now when I try to push my local development, I get a message that my local branch is behind, so I should pull before pushing
  • however, I actually want my local development to become the remote development again, and for feature/a to continue separately for now as it has been

I'm not super-clear as to what git command sequence would give me the above resolution, and I really don't want to lose my (or anyone else's!) commit history!

1 Answers

for feature/a to continue separately for now as it has been

If feature/a is currently represented by the development branch (in its present state)

git checkout -b feature-a development
# or, with Git 2.23
git switch -c feature-a development

That will create a new local branch for feature-a, and you are free to reset development.

I actually want my local development to become the remote development again, and

 git fetch
 # make sure you don't have any work in progress first
 git checkout development
 git reset --hard origin/development
Related