idksoiputthis
idksoiputthis

Reputation: 121

If i remove a commit from one branch, will that same commit be removed from the other?

Somehow, I made a commit to the master branch and a different branch.
So the exact same commit ID is present for my master branch and the other branch.

I already created the pull request on the other branch to apply the changes to the upstream repo. (The pull request is not yet approved).

The problem is that I just found out that again, the same commit made in that PR is on my master branch. I figured that out after I made a new branch off of master and made a new commit for a different PR.
So now when attempting to make a new PR for this new branch, it includes the commit that was on the master since I made the branch off of master.

I want to know that if I delete the commit off of master branch, will it effect the commit made on the other branch that is in my active PR?
(because they are referenced to by the same commit ID)

Upvotes: 0

Views: 1144

Answers (2)

Vinod Kumar
Vinod Kumar

Reputation: 592

Commit or resetting the head in separate branch remains in that branch itself. It is not auto replicated. You need to perform

git reset HEAD commit_id or git reset HEAD~1
on both master branch and the other branch that you have manually created.

Upvotes: 0

VonC
VonC

Reputation: 1326556

I want to know that if I delete the commit off of master branch, will it effect the commit made on the other branch that is in my active PR?

No it will not:

  • deletion of a commit (for instance through a git reset --hard @~) is a local operation
  • the commit isn't really "deleted", master HEAD simply points to its previous commit, assuming your was the most recent on master branch
  • even if you force push your master branch (and publish your deletion), that won't affect the remote PR branch

Upvotes: 1

Related Questions