代码之家  ›  专栏  ›  技术社区  ›  naimdjon

Git:自动修复功能分支中的提交

  •  1
  • naimdjon  · 技术社区  · 6 年前

    当我完成一个特性时,我通常希望自动修复一个提交,然后在合并到master之前强制推送到一个远程源。

    2 回复  |  直到 6 年前
        1
  •  4
  •   Matthieu Moy    6 年前

    您可以在中保存手动编辑提交列表的步骤 rebase -i 使用 git commit --fixup <commit> 在制作修复时提交。那么,如果 rebase.autoSquash 设置为真, git rebase -i 将自动将包含此提交的行转换为 fixup 在提交修复程序的正下方的行。

        2
  •  4
  •   stijn    4 年前

    $ git commit -a --amend --no-edit
    

    不过,你还是得用力推。

    这是一个细分的数据 git commit 上面使用的选项:

    -a, --all: 
    Tell the command to automatically stage files that have been modified and 
    deleted, but new files you have not told Git about are not affected.
    
    --amend: 
    Replace the tip of the current branch by creating a new commit.
    
    --no-edit: 
    Use the selected commit message without launching an editor. 
    For example, `git commit --amend --no-edit` amends a commit without changing 
    its commit message.
    
        3
  •  0
  •   Antoine Boucher    5 年前
    git commit -a --amend --no-edit && git push -f