V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
yantianqi
V2EX  ›  程序员

git 中 amend 是什么意思?

  •  
  •   yantianqi · 2017-08-08 22:08:31 +08:00 · 3635 次点击
    这是一个创建于 2454 天前的主题,其中的信息可能已经有所发展或是发生改变。

    git 中 amend 是什么意思

    11 条回复    2017-08-11 02:03:17 +08:00
    hellohello123
        1
    hellohello123  
       2017-08-08 22:12:51 +08:00
    当前分支?
    FrankFang128
        2
    FrankFang128  
       2017-08-08 22:14:18 +08:00
    修复前一个 commit
    yantianqi
        3
    yantianqi  
    OP
       2017-08-08 22:16:26 +08:00
    @FrankFang128 提交完后,发现打上 amend 对勾有出现好几个暂存区的更改,要不要提交呢?操作和不操作有什么区别呢?
    beginor
        4
    beginor  
       2017-08-08 22:16:55 +08:00 via Android   ❤️ 1
    我理解为 append, 将工作区的更改添加到上一次 commit,前提上一次 commit 没有 push 到远程服务器
    wenzhoou
        5
    wenzhoou  
       2017-08-08 22:19:58 +08:00 via Android
    「 amend 」
    動詞
    修改
    modify, amend, revise, alter
    修正
    correct, amend, revise
    改正
    correct, amend, put right

    make up, supplement, patch, repair, mend, amend

    repent, reform, amend
    拨正
    amend, correct, mend, rectify, remedy, right

    这样记忆 i ‘ m end=我完蛋了
    Biwood
        6
    Biwood  
       2017-08-08 23:04:26 +08:00
    居然不是用命令行,我只知道 git commit 的时候,加上 amend 参数可以用来修改上一次提交的信息
    oaix
        7
    oaix  
       2017-08-08 23:30:36 +08:00
    其实就是 git reset HEAD^和 git commit 两条命令的快捷方法
    inflationaaron
        8
    inflationaaron  
       2017-08-09 02:14:02 +08:00
    amend 生成的 commit 有一个全新的 hash,所以如果老 commit 已经 push 了就尽量不要用 amend,会给其他 contributer 造成麻烦。
    hantsy
        9
    hantsy  
       2017-08-09 12:52:29 +08:00
    @FrankFang128 不是。

    @Biwood 之前有项目,我们要求 Commit 的 Comments 必须规范。而经常 Commit 是好习惯,但是发现,上次 Commit 有问题,少了文件或者功能上有问题,而新的 Commit 中并包含什么太多的新功能,仅仅是补充上次 Commit,理论上如果两次合并成一次 Commit 更为合理。
    所以 amend 的派上用场。新的 Commit,可以重新编辑上次 Comment。

    @inflationaaron 对于一些正在开发的新功能(可能是一个任务的 Checklist )没必要一 Commit 对应一个 Push 的,通常我也是多次 Commit (每次 Commit 完成 CheckList 中的一个项目) 再 Push 上去。
    Williamp
        10
    Williamp  
       2017-08-09 17:05:26 +08:00
    Simply meaning of git is a foolish but in the meaning of change, its meaning is 'disagreeable person'.
    inflationaaron
        11
    inflationaaron  
       2017-08-11 02:03:17 +08:00
    @hantsy `git rebase -i` 有这样的作用啊,把多个 commit 合成一个。反正都是 local 的 branch 只要没有别人 checkout,随便怎么搞都行
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2913 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 14:31 · PVG 22:31 · LAX 07:31 · JFK 10:31
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.