简体   繁体   中英

How to remove a commit from Sourcetree github project

I just renamed a field in my project that later I understood that caused my app to crash now. I want to reverse my commit to an earlier commit and edit and write my code from there. Now, the problem is when I reset the branch to that commit and I want to make new pushes, it tells me that I have to pull first because the branch is behind. I can't push. I am working on Sourcetree in Windows. Any idea how to fix that? https://i.stack.imgur.com/y08cb.jpg I added the image to better understand here. I want to reset to df .

更改命名之前

If you don't care about the commits after df , you can do an hard reset in SourceTree to df commit.

Right-click on df , and select "reset current branch to this commit".
Note that this will implies to force push , which is OK if you are the only one working on that project.

In SourceTree, select the last "good" commit (ie one older than the one you want to delete). Then call Repository -> Interactive Rebase... . You can change the complete revision history here. When done, push and make sure to check the "Force Push" checkbox at the bottom of the dialog.

If the checkbox is grayed out, you need to enable it first: open Tools -> Options , tab Git . Check "Enable Force Push".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM