Home

Git Tip: Removing dependency of one commit on another

For removing dependency of one commit over another, you may use Git’s interactive rebase. Following is a simple tutorial to help you with that:

Let us suppose, following commits are appearing in your `git log`, where you want first commit to be dependent on third commit, instead of its current dependency on the second change-set.

$ git log –pretty=oneline

680f3f160054fcfa92010238e23070300 Bloom-filter implementation

d8084b31608292841945d373bd614d3 Test-case for concurrent sessions

4c71a9167d7f9d8cf53tya34562d67e10 Infinite scroll for logs

For this purpose, you may perform interactive rebasing by executing following command:

$ git rebase -i 4c71a9167d7f9d8cf53tya34562d67e10

As soon as you run the command, Git editor having following statements, may open up:

pick d8084b3 Test-case for concurrent sessions with UI
pick 680f3f1 Fix for bug in bloom-filter implementation

Remove the line corresponding to the change-set(s) you don’t want, which will tell Git not to “pick” it, while performing the interactive rebase process. Save and close the editor. Doing so will remove dependency of the first commit on the second one, as was intended. You should validate this via `git log`.

Note: While rebasing, some conflicts may appear, which you will have to satisfy and then continue the rebasing process.

 

 

 

 



Subscribe: rss | email