質問

Having the structure shown in the picture, Can I delete the commits 0ec08281 and 21736a48? I think that maybe I could do it using rebase but I'm afraid of deleting also the last commits.

history

Edit: I forgot to mention that the commits were pushed to the remote server. However now I'm the only one with access to that server (at least up to now) so there is no chance of messing the source code to other people.

役に立ちましたか?

解決

You can use an interactive rebase (using the -i) argument, and delete the hashes of the commits that you wish to remove.

Providing you have not pushed your changes to a shared repository yet. Find more information here: *http://git-scm.com/book/en/Git-Tools-Rewriting-History*

e.g. git rebase -i 22782e08

That should be fine, remember any commit id that is deleted in the interactive script window will be removed, if you wish to abort, delete ALL the commits from the script. There will be on screen instructions regarding this.

Out of interest, why are you deleting them? The graph looks fine to me, if you're doing it for tidiness reasons.

他のヒント

Interactive rebase is not a good idea if you have pushed the changes, you'll be rewriting history.

A better way is to revert the changes you don't want

git revert 22782e08

etc

This will create a new commit that undoes the changes in the commit you are reverting.

This is better, because it doesn't change history, but undoes the changes.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top