Pawan
Pawan

Reputation: 32331

Git : how can i remove a particular commit from a branch

I have two brances namely master and development . All the development will be done inside the development branch and will be merged with master for the build .

I checked out master branch and cherry picked 5 commits belonging to the development branch and pushed it to the master remote repository .

All these things went fine .

git checkout master 
git status
git cherry-pick a7644fc2bc7b09fe88cb1cbb75e0547dd1d7321d
git cherry-pick 335bf121a6aa7bc1e334b94d1a742b0f9ecfb9b6
git cherry-pick 5dee244a47d0346d5080ecd34984683c8f442c93
git cherry-pick 9f8fe22b346ba80089126afbf29ac063ea7b9b32
git cherry-pick 5dee244a47d0346d5080ecd34984683c8f442c9h
git push

Now my reqirement is that i need to remove one of the cherry pick from the master to do the build .

I am not sure , but when i googled i found these two commands

git revert --strategy resolve

git rebase 

Please let me know how can i remove a particular commit from the master branch

Updated Part

When i did git revert 564d01c3870ca5a55b171fc6f061e0cc2a8f4879 this screen came up , can i avoid this ??

enter image description here

Upvotes: 0

Views: 1768

Answers (1)

kmkaplan
kmkaplan

Reputation: 18960

Use git revert <commit>. If you do not want the editor to popup use --no-edit option. If you do not want to actually commit the revert, just apply it to your working directory, use the --no-commit option.

If you only pushed to controlled repository and you positively know nobody pulled from it then you can do some git reset --hard <commit>^ and then re-cherry-pick the commits you actually want. But this is not recommended.

Upvotes: 2

Related Questions