Today I Learned

Giant Monkeys Learning

4 posts about #Git

git commits from then to now

To show all commit children from a specific commit to current master, use git log like bash git log --reverse --ancestry-path 894e8b4e93d8f3^..master

Method git history with `git log -L`

Today I found out that - via git log -L - it's possible to list the history of changes to a specific method:

$ git log -L :initialize:app/lib/giant_money.rb -n5

commit e6ef7f8a3cf06af2ecbf8a528ad5cf312a8d03b1
Author: Alexander Presber <post@momolog.info>
Date:   Sun Aug 13 20:05:59 2023 +0200

    don't fail hard (yet) on GiantMoney[nil] [GOM-8932]

diff --git a/app/lib/giant_money.rb b/app/lib/giant_money.rb
--- a/app/lib/giant_money.rb
+++ b/app/lib/giant_money.rb
@@ -16,12 +16,16 @@
   def initialize value, allow_nil: false
-    raise "GiantMoney.new: value cannot be nil." unless value || allow_nil
+
+    unless value || allow_nil
+      # raise "GiantMoney.new: value cannot be nil." # don't fail hard (yet) on GiantMoney[nil]
+      Rollbar.error("GiantMoney.new: value cannot be nil in #{caller[2]}.", stack: caller)
+    end

     @amount = case value
       when nil      then nil
       when Money    then value
       when Integer  then Money.new(value)
       when Float    then Money.new((value * 100.0))
       else raise 'GiantMoney.new: value needs to be an Integer, Float or Money object.'
     end
   end


commit f55678a8c33029b1e998e1e0b6d536afd2f77107
Author: Lion Vollnhals <lion@giantmonkey.de>
Date:   Fri Jun 9 12:58:05 2023 +0000

    giant_monkey: multiple float by float

diff --git a/app/lib/giant_money.rb b/app/lib/giant_money.rb
--- a/app/lib/giant_money.rb
+++ b/app/lib/giant_money.rb
@@ -16,12 +16,12 @@
   def initialize value, allow_nil: false
...

Noice.

Ours and theirs in git rebase

When resolving a conflict while doing a git rebase, --ours does not refer to the branch we are currently on (the one being rebased) but the base branch, e.g. main.

While arguably being pretty confusing, this actually has a good reason.

A nice cheat sheet is here.

Rebase without having anything pushed yet

Prototyping should also be cleaning up commits before first push. How to do that?

Well, git rebase --interactive --root masterdoes the trick.

Thanks to https://troglobit.com/howto/rebase-without-an-origin/