Move specific git commit from master to branch

amo

I have a specific commit that was pushed into origin/master but was not ready for prime time. It should have gone into a separate existing feature branch that will eventually be merged into master. How can I pluck the commit out of master and move it into the feature branch?

Here's what I have in the remote branches:

          a     B     c     d
master -  o --- o --- o --- o -->
                   \
newbranch -         - o --- o -->
                      p     q

The errant commit B needs to be moved to newbranch:

          a     c     d
master -  o --- o --- o -->
             \
newbranch -   - o --- o --- o -->
                B     p     q

Is this possible to achieve?

Oliver Charlesworth

If you have already pushed the commit, then any attempt to rewrite the existing graph will require a force-push, which will make other members of your team sad.

Therefore, the best solution is to simply commit a revert to master:

git checkout master
git revert B   # Or whatever the commit hash for B is

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Move specific git commit from master to branch

From Dev

Git move single commit from feature_branch to master

From Dev

Git move single commit from feature_branch to master

From Dev

Git Move Not-Pushed Commit from temp to master branch

From Dev

move branch from master commit to previous master commit

From Dev

move branch from master commit to previous master commit

From Dev

Git - Move feature branch ancestor pointer to latest commit on Master

From Dev

How to move later created branch before first commit on master branch in git?

From Dev

Merge a commit from Develop to Master branch in the "successful git branching model"

From Dev

Delete a file from a branch and commit it back to the master in Github/Git?

From Dev

Delete a file from a branch and commit it back to the master in Github/Git?

From Dev

Forgot to branch in git, need to move changes from master

From Dev

Forgot to branch in git, need to move changes from master

From Dev

Prepend a commit from master to a branch

From Dev

push from git/svn repo into a git/branch at specific commit

From Dev

Rebasing a remote (master) branch to a specific commit

From Dev

How to move my new branch to the latest commit in master branch?

From Dev

git update branch after commit on master

From Dev

How do I move a commit from master to a branch while preserving its Gerrit ID?

From Dev

forget to move to another branch than master with Git

From Dev

git branch from branch instead of from master

From Dev

Git branch diverged from master

From Dev

Git rebase/master changes from branch into master

From Dev

Git rebase/master changes from branch into master

From Dev

git replace a commit by a commit from another branch

From Dev

Move a local commit to un-master local branch

From Dev

Move a local commit to un-master local branch

From Dev

Copy specific Git commits to master branch

From Dev

Git deploy master branch or particular commit or tag with chef git resource

Related Related

  1. 1

    Move specific git commit from master to branch

  2. 2

    Git move single commit from feature_branch to master

  3. 3

    Git move single commit from feature_branch to master

  4. 4

    Git Move Not-Pushed Commit from temp to master branch

  5. 5

    move branch from master commit to previous master commit

  6. 6

    move branch from master commit to previous master commit

  7. 7

    Git - Move feature branch ancestor pointer to latest commit on Master

  8. 8

    How to move later created branch before first commit on master branch in git?

  9. 9

    Merge a commit from Develop to Master branch in the "successful git branching model"

  10. 10

    Delete a file from a branch and commit it back to the master in Github/Git?

  11. 11

    Delete a file from a branch and commit it back to the master in Github/Git?

  12. 12

    Forgot to branch in git, need to move changes from master

  13. 13

    Forgot to branch in git, need to move changes from master

  14. 14

    Prepend a commit from master to a branch

  15. 15

    push from git/svn repo into a git/branch at specific commit

  16. 16

    Rebasing a remote (master) branch to a specific commit

  17. 17

    How to move my new branch to the latest commit in master branch?

  18. 18

    git update branch after commit on master

  19. 19

    How do I move a commit from master to a branch while preserving its Gerrit ID?

  20. 20

    forget to move to another branch than master with Git

  21. 21

    git branch from branch instead of from master

  22. 22

    Git branch diverged from master

  23. 23

    Git rebase/master changes from branch into master

  24. 24

    Git rebase/master changes from branch into master

  25. 25

    git replace a commit by a commit from another branch

  26. 26

    Move a local commit to un-master local branch

  27. 27

    Move a local commit to un-master local branch

  28. 28

    Copy specific Git commits to master branch

  29. 29

    Git deploy master branch or particular commit or tag with chef git resource

HotTag

Archive