美文网首页
Git commit --amend --no-edit

Git commit --amend --no-edit

作者: JaedenKil | 来源:发表于2019-03-29 15:20 被阅读0次

    When I was working on a repo, something strange occurred.

    # Local repo
    $ git log --oneline -3
    4030437 (HEAD -> optimize_dumpUi) Optimize assert button exist method
    6a23ff5 (upstream/master, master) Merge branch 'issue_update_unit' of JaedenKil/Perf-MLBench-DEBUSQA into master
    b21a7af (origin/issue_update_unit, issue_update_unit) Update test result unit
    
    # Remote repo
    $ git log origin/optimize_dumpUi --oneline -3
    f9b9099 (origin/optimize_dumpUi) Optimize assert button exist method
    6a23ff5 (upstream/master, master) Merge branch 'issue_update_unit' of JaedenKil/Perf-MLBench-DEBUSQA into master
    b21a7af (origin/issue_update_unit, issue_update_unit) Update test result unit
    

    After a check, found the newest commit of both repositories are exactly the same except for the commit id.
    So:

    $ git reflog -6
    4030437 (HEAD -> optimize_dumpUi) HEAD@{0}: commit (amend): Optimize assert button exist method
    f9b9099 (origin/optimize_dumpUi) HEAD@{1}: commit: Optimize assert button exist method
    6a23ff5 (upstream/master, master) HEAD@{2}: checkout: moving from master to optimize_dumpUi
    6a23ff5 (upstream/master, master) HEAD@{3}: merge upstream/master: Fast-forward
    179091b (origin/master) HEAD@{4}: checkout: moving from issue_update_unit to master
    b21a7af (origin/issue_update_unit, issue_update_unit) HEAD@{5}: commit: Update test result unit
    

    Finally, commit (amend) shows I made a commit, then used git commit --amend, thus leading to different commit id.

    git diff f9b90 40304
    ...
    -            Log.i(TAG, prefix + "Target UiObject '" + objName + " exists.");
    +            Log.i(TAG, prefix + "Target UiObject '" + objName + "' exists.");
    

    So the problem was caused by adding a colon...
    In the end, git push -f is needed. Luckily this is not on the master branch.

    相关文章

      网友评论

          本文标题:Git commit --amend --no-edit

          本文链接:https://www.haomeiwen.com/subject/gjilbqtx.html