Git rewrite history - How to modify a specified commit in git

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

I usually submit a list of commits for review. If I have:

    • HEAD
    • Commit3
    • Commit2
    • Commit1

I know that I can modify head commit with git commit --amend, but how can I modify Commit1 , given that it is not the HEAD commit?

Answers

You can use git rebase, for example, if you want to modify back to commit bbc643cd, run

$ git rebase --interactive  bbc643cd^ 

In the default editor, modify pick to edit in the line whose commit you want to modify. Make your changes and then commit them with the same message you had before:

$ git commit --all --amend --no-edit

to modify the commit, and after that

$ git rebase --continue

to return back to the previous head commit.

http://stackoverflow.com/a/3926832/1269037 http://stackoverflow.com/a/3926832/1269037

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/1186535/how-to-modify-a-specified-commit-in-git

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils