Coder Social home page Coder Social logo

Comments (8)

tsechingho avatar tsechingho commented on June 1, 2024

如果你的 commit 內容很亂,常 merge 別的 branch 到你的 branch,加上別人不會 review 你的 commit,那 merge 的確夠用。

rebase 最大的用途是,整理你的 commit,讓別人容易看懂你的 commit。
it should always keep your branch on top of other branches (before send pull request).

如果你每天要幫別人 review 很多 commits,有邏輯的 commits & message,簡單的 branch,才能幫你省下很多時間。

from ama.

puff-tw avatar puff-tw commented on June 1, 2024

我覺得應該會常用到耶。
因為我時候都會做 fix typo 的 commit ,導致我的 commit message 有點亂。

比方說我有四個 commit message
Implement feature A
fix typo
fix typo
Implement feature B

可是你只是要其中兩個
Implement feature A
Implement feature B

from ama.

marsz avatar marsz commented on June 1, 2024

首先,feature/xxx 是你正在開發中的分支,base 為 commit C

master:       A -> B -> C
feature/xxx: (A)->(B)->(C)-> D

有別人更新了 master 分支,且你的 feature/xxx 可能會需要因應 master 分支的更新 (commit E, F ) 修改時...

master:       A -> B -> C -> E -> F
feature/xxx: (A)->(B)->(C)-> D

master 進行 rebase 後,可以讓 feature/xxx 的 base ( commit C) 也更新到和 master 一樣新 (commit F)

master:       A -> B ->  C -> E ->  F
feature/xxx: (A)->(B)->(C)->(E)->(F)->D

以上,是除了 merge branch 以外,我覺得 rebase 最常用到的情境之一 :)

from ama.

adlerhsieh avatar adlerhsieh commented on June 1, 2024

認同 @puff-tw ,rebase的目的是整理,如果commits本身可以忽略,就應該要使用rebase合在一起。反之如果覺得merge訊息是必要的,那就保留merge的commit。

from ama.

JuanitoFatas avatar JuanitoFatas commented on June 1, 2024

這個 4 分 20 秒的影片解釋的蠻清楚的,可以參考看看:

screenshot 2015-09-25 15 03 26

Rebase:

  1. 去除、整併無謂的 Commits 😍
  2. 與 Source Branch 同步
  3. 保持乾淨歷史(貢獻開源專案)🎈
  4. 可以對特定 Commit 進行修正 🙈

另可參考 Thoughtbot Git Protocol 這篇來了解為什麼開發時要 rebase 😉

from ama.

JuanitoFatas avatar JuanitoFatas commented on June 1, 2024

I take the liberty to close this issue 😉 I think this issue already got enough 🍖.

Thanks everyone! 😘

from ama.

CarolHsu avatar CarolHsu commented on June 1, 2024

@JuanitoFatas Helpful video, thanks!

from ama.

bugtender avatar bugtender commented on June 1, 2024

@tsechingho @puff-tw @marsz @adlerhsieh @JuanitoFatas

感謝大家的回覆,
可能我專案都是自己開發居多,忽略了共同開發時 commit 的可讀性 😞

看完回覆之後今天自己又動手做了幾次,
已經了解為何要使用rebase了,非常謝謝大家! 👍

from ama.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.