怎样更改Git的commit?
在使用git的时候,避免不了要更改某一个或某一些commit,这个时候就需要使用git rebase命令了。
假如说当前repository中共有两个commit, 05034eefd8670787d0f2cf6a67a2798b31c676b5(Initial commit), c9e03a2805b3b7c101b77ecaf5ac4f9a96759f64(just for test)。
怎样更改Git的commit?
由于种种原因想同时修改这两个commit的信息,比如说author信息。该怎么做呢?
(1)更改根commit的author信息
    # checkout root commit
     git checkout 05034eef
    # amend the commit
    git commit --amend --author="JerryKwan <JerryKwan@gmail.com>"
(2)在修改后的根commit基础之上更改后续commit
    # rebase all the other commits in master onto the amended root
    git rebase -i --onto HEAD HEAD master
    # change pick command to edit command
    在rebase -i 的 提示的所有需要rebase的commit列表中将pick命令更改成edit
    # continue amend the commit
    git commit --amend --author="JerryKwan <JerryKwan@gmail.com>"



相关文章:

  • 2021-07-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-09
  • 2021-10-13
  • 2021-04-25
猜你喜欢
  • 2022-03-06
  • 2021-07-10
  • 2021-11-05
  • 2022-12-23
  • 2021-12-04
  • 2021-08-10
  • 2021-06-16
相关资源
相似解决方案