Edit the root commit in Git?

前端 未结 5 1249
予麋鹿
予麋鹿 2020-11-22 16:33

There\'s ways to change the message from later commits:

git commit --amend                    # for the most recent co         


        
5条回答
  •  野性不改
    2020-11-22 17:21

    You could use git filter-branch:

    cd test
    git init
    
    touch initial
    git add -A
    git commit -m "Initial commit"
    
    touch a
    git add -A
    git commit -m "a"
    
    touch b
    git add -A
    git commit -m "b"
    
    git log
    
    -->
    8e6b49e... b
    945e92a... a
    72fc158... Initial commit
    
    git filter-branch --msg-filter \
    "sed \"s|^Initial commit|New initial commit|g\"" -- --all
    
    git log
    -->
    c5988ea... b
    e0331fd... a
    51995f1... New initial commit
    

提交回复
热议问题