paswes
paswes

Reputation: 61

GIT fix commits in local branch (and remote)

I have 2 branches with commits.

Branch B looks something like:

  1. commit from Branch B
  2. commit from Branch B
  3. commit from Branch A
  4. commit from Branch A
  5. commit from Branch A
  6. commit from Branch A
  7. commit from Branch A

This happened because of a wrong rebase..

Before I make a merge request for Branch B I would like to fix it and remove all commits from Branch A.

What is the best way of doing this?

Upvotes: 1

Views: 157

Answers (1)

Monish Khatri
Monish Khatri

Reputation: 980

You can use git rebase -i HEAD~n, Here n is the number of commit you want see in the bash and change them.

Steps(In your case) :

  • git rebase -i HEAD~7
  • Then simply replace the pick word with drop for commit's you want to delete from branch B
  • Then save the bash file and exit.
  • git push --force-with-lease <remote> branch B OR git push -f <remote> branch B it will push your lastest changes (without branch A's commit)

Upvotes: 2

Related Questions