search

Home  >  Q&A  >  body text

github - Git 感觉无用/多余的 commit 状态可以删掉吗 ?

Git 还不怎么熟 , 我想问下 .
历史提交的commit , 如果以后这个项目目录太大 , 可以把一些历史状态删掉吗 ?

这样可以节省很多空间

世界只因有你世界只因有你2811 days ago845

reply all(6)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-05-02 09:24:25

    1. Submissions that have been uploaded to the server, whether reset or rebase, will be rejected by teammates;
    2. Excessive submissions will only record the changes. If they are all positive modifications, they will not increase the size, but are the recommended best practice strategies;
    3. When you have permission to reset the server, you just force your local and server to jump to the corresponding submission; your teammates are still at the original position, and the result of them updating and submitting again will be very dramatic;
    4. Rebase is good for your local and server in this case; your teammates will scold you and create a new branch for me, which is not beautiful at all. At the same time, the redundancy of local submissions has really increased. ..

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-02 09:24:25

    git rebase -i

    reply
    0
  • 为情所困

    为情所困2017-05-02 09:24:25

    Yes, you can find it just by searching

    git reset --hard <commit_id>
    
    git push origin HEAD --force
    
    
    

    But I really don’t recommend doing this.

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-02 09:24:25

    @AlexChen has already said to do it through the reset command:

     git reset --hard <SOME-COMMIT>
    

    The effect of this command is to undo all commits after this commit. You can also do it through the revert command:

    git revert <SOME-COMMIT>
    

    The effect is to cancel a certain submission.
    This is indeed very risky, so be careful.

    reply
    0
  • PHPz

    PHPz2017-05-02 09:24:25

    In my impression, the rebase command can merge redundant commits

    http://www.ruanyifeng.com/blog/2015/08/git-use-process.html
    Refer to this article

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-02 09:24:25

    means git commit just save file changes, so it won’t take up much space

    reply
    0
  • Cancelreply