Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you just want to change the commit that the branch points to you need to reset.</p> <pre><code>git reset --hard 30735f3d4884c4156a070f75dbc5ae3608f9c312 </code></pre> <p>However, this will put you "behind" in history when compared to origin. As a result you can't simply push. You have to force push.</p> <p>git push -f origin </p> <p>The problem with this is this. If other developers have copies of this branch locally, they will each have to dot he following.</p> <pre><code>git fetch git reset --hard origin/&lt;branch&gt; </code></pre> <p>This will get complicated if they have commits locally that they need to preserve, as the command above will mean that they will lose those. <strong>Its generally a bad idea to modify history that has already been shared with others.</strong></p> <p>Alternatively, if this is code that other developers already share with you, you may want to use `git-revert' to "undo" all those merge commits after the one want.</p> <pre><code>git revert 823da1cf7976466da40a5720191d09b080e046d6 git revert be87e784da99fbad8b575b5433bb33a35954064c </code></pre> <p>This will create two "revert" commits, which will undo the <em>changes</em> that those merge commits made. Making your history look like this.</p> <pre><code>* ######################################## Revert be87e78 Merge branch 'dev' * ######################################## Revert 823da1c Merge branch 'hotfix#1-issue * 823da1cf7976466da40a5720191d09b080e046d6 Merge branch 'hotfix#1-issue |\ | * 71b732ef9ecbf36153ab2729cc78bc522341399e fixed: changed salary type f |/ * be87e784da99fbad8b575b5433bb33a35954064c Merge branch 'dev' |\ | * 90b23296a3a6c2883f2c434947da4896d8afef5c Merge branch 'issue#2240' | |\ |/ / | * 947b43b12763acbd0ca2733f0fd88e3882c086ab issue#2240:create user class |/ * 30735f3d4884c4156a070f75dbc5ae3608f9c312 Merge branch 'dev' </code></pre> <p>This you can push, and everyone can pull - it will be the same state of code that existed in <code>30735f3d4884c4156a070f75dbc5ae3608f9c312</code>.</p> <p><strong>Important</strong></p> <p>If you chose to revert merge commits, be aware of what is actually happening. If you want to re-introduce the changes from the reverted merges, you will need to revert the revert commits. <a href="https://stackoverflow.com/questions/15736564/why-after-merge-does-git-say-already-upto-date-but-differences-between-branch/15737656#15737656">Read this answer from me to a different question regarding reverting and merge commits.</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload