harv3
harv3

Reputation: 303

Deleting commits from a branch in which other branchs are merged

I have three branches - A(branch I am working on), B, C.

The commit history of branches B and C looks like this

Branch B

Branch C

I have merged these branches into Branch A, So commit history for A looks like this

I want to reset my branch A to commit a1 using git reset --hard a1. If I do this does commit b1,b2 and c1, c2 gets removed from branches B and C as well or they get removed from only branch A?

Upvotes: 0

Views: 34

Answers (2)

Daly
Daly

Reputation: 879

No, git reset --hard a1 will not change any of the commits on branches B or C. However you will lose the work in commit a2 unless it is saved elsewhere.

Upvotes: 1

Rahul Bhobe
Rahul Bhobe

Reputation: 4451

A hard reset on Branch A will affect only that branch. The the other branches will remain unaffected.

To answer your question - After a hard reset of Branch A with (git reset --hard a1), the commits b1 and b2 will remain in Branch B and the commits c1 and c2 will remain in Branch C.

Upvotes: 1

Related Questions