0

I'm working on a feature branch, that has been pretty inactive. Recently, some changes have been made to the remote master branch, so I ran git checkout master and git pull. Then, I went into my feature branch and ran 'git rebase master' and resolved a lot of merge conflicts and ':qa!'d' the vim sessions asking for commit messages.

I then tried to push this rebase'd branch got GitHub, and it said my remote branch was out of date with the local branch, so I googled this and SO said to run git pull 'featurebranch' first, resolve merge conflcits again, and then run git push 'featurebranch'.

So I did this, and my existing pull request with 20 commits for this feature branch jumped to 150+ commits all of a sudden. Now, I'm really lost on how exactly to revert all of this. How can I undo the rebases, merges, and 150+ commits in the PR for the feature branch? Basically, just as if the past few git changes never happened.

Is there a way to do this?

Will 'git reset --hard feature@{24.hours.ago} work? How to then update the PR? How to "time travel" git repository back in revisions?

Update: I ran git reflog, found the commit ID prior to the rebases and ran git reset --hard (ID). Now that I'm going to do this in the actual feature branch, how do I push the reset'd branch version to the github PR I have open for it. Will it delete the new commits added from the merge/rebase?

1 Answers1

0

I don't fully understand what's your problem.

how do I push the reset'd branch version to the github PR I have open for it?

You can not PR by command line. But if you have create a PR from feature branch to master branch, you can just git push origin featrue-branch-name.

Will it delete the new commits added from the merge/rebase?

No, if you push success, remote branch should equal to local branch. Your commits from local branch will not be delete. but if you use -f, the commits from remote branch which is different from local branch will be delete.

The normal way to rebase feat-branch to master is:

git checkout feature-branch-name
# do some edit
git add --all .
git commit -m "update message"
git rebase master
# solve confilcts
git add /path/to/confilcts/file
git rebase --continue
git push origin feature-branch-name
# then click PR(from feat-branch to master) in github

If you push failed, git push -f origin feature-branch-name, to force make remote branch sync to you local branch

Sangria
  • 134
  • 8