Timeline for Git, How to reset origin/master to a commit?
Current License: CC BY-SA 3.0
22 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 28, 2023 at 7:34 | comment | added | MJimitater | Is force pushing really best practise and better to somehow merge a branch with the changes into master? Isn't force pushing into master too dangerous? | |
Jul 7, 2023 at 7:47 | comment | added | lyolikaa | same commands can be done via Git Extensions, reset to commit and push | |
Nov 8, 2022 at 5:14 | comment | added | jpulikkottil | davidbits.blogspot.com/2022/11/… | |
Nov 29, 2021 at 12:34 | comment | added | Thiago | It may be easier if you manually delete that branch from origin, before pushing the edited branch. | |
Mar 9, 2020 at 11:11 | comment | added | Max MacLeod | @SeanMalter commits are never lost. Although it may be that they are no longer in the ancestor hierarchy. | |
Jul 29, 2019 at 23:40 | comment | added | Sean Malter | NOTE: you lose your local commits | |
Aug 16, 2016 at 19:59 | comment | added | entpnerd |
@SimonBoudrias when I execute git reflog I only see the commits before the reset point in addition to the reset and rebases that were performed by the git reset command. Also, when I check SourceTree, I don't see the commit ID of the pushes to the origin that happened after the reset point. It's like they never happened. That being said, your solution does correctly reset the origin. From my point of view, I just don't the retention of reseted commits, but it did work. :-)
|
|
Aug 16, 2016 at 18:59 | comment | added | Simon Boudrias |
@entpnerd check git reflog to find the commits you deleted.
|
|
Aug 16, 2016 at 17:43 | comment | added | entpnerd | On my machine, it appears to blow away the actual previous pushes you were undoing. For example, after doing the forced push, all future entries in git log are no longer there, so I see no way of recovering the code changes that were undone. | |
Oct 22, 2015 at 17:29 | comment | added | BadHorsie | After doing this, I have two tagged commits ahead of where I reset master to, which didn't go away. How do I delete those entries? | |
Jan 19, 2015 at 11:16 | comment | added | m0skit0 | Yes, I know. In this case I don't mind losing the history because all commits are in fact a merge from another branch. I am in charge of the git server and I don't want to allow non-fast-forward commits. | |
Jan 19, 2015 at 5:01 | comment | added | Simon Boudrias | @m0skit0 reverting in git words mean creating a new commit on top of a branch changing back the chances introduced in an older commit. So it doesn't change the history of a branch. You can also just ask the person in charge of your git server to re-allow non-fast-forward commits. | |
Jan 17, 2015 at 17:21 | comment | added | m0skit0 |
Erm... No, it doesn't work. I cannot revert all changes because then it says there's a merge. And if I use -m I got the message posted. git push origin :master , reverting to commit I want origin to have and pusing it, did work though.
|
|
Jan 17, 2015 at 0:11 | comment | added | Simon Boudrias | @m0skit0 It does work. It is your git server who's doing custom magic with git-hooks. This mean you won't be able to reset origin/master. Your only option is to revert changes in a new commit. | |
Jan 16, 2015 at 10:36 | comment | added | m0skit0 |
Doesn't work. remote: error: denying non-fast-forward refs/heads/master (you should pull first)
|
|
Nov 19, 2014 at 12:33 | review | Suggested edits | |||
Nov 19, 2014 at 13:15 | |||||
May 9, 2014 at 1:05 | comment | added | Nick W. | Agreed, had to do this today after accidentally merging the wrong branches together then pushing to origin. It works well, but it could be very disruptive if other people have been checking out the affected branches from origin. Use with caution. | |
Dec 20, 2013 at 20:53 | comment | added | Simon Boudrias | You shouldn't care about origin/HEAD, simply push the good ref to origin/ref | |
Dec 20, 2013 at 20:29 | comment | added | Daniil Shevelev | I followed this steps and it rolled back. But the origin/HEAD is now pointing to a branch other than master. What can I do to fix this? | |
Jul 16, 2013 at 6:13 | comment | added | mnagel | that does the requested operation, but keep in mind that it will make unhappy those people who already pulled the commits from master. | |
Jul 16, 2013 at 2:41 | vote | accept | Hesam | ||
Jul 16, 2013 at 2:30 | history | answered | Simon Boudrias | CC BY-SA 3.0 |