IchHabRecht icon

[GIT] Add new file to existing commit with filter-branch

IchHabRecht | PRO | 07/24/16 10:47:27 AM UTC | 0 ⭐ | 299 👁️ | Never ⏰ | []
Bash |

400 B

|

None

|

0 👍

/

0 👎

#!/bin/bash
file_path=composer.json
before_commit=$(git rev-parse --verify 5942ce7)
file_blob=$(git hash-object -w "$file_path")
git filter-branch \
  --index-filter '
 
    if x=$(git rev-list -1 "$GIT_COMMIT" --not '"$before_commit"') &&
       test -n "$x"; then
         git update-index --add --cacheinfo 100644 '"$file_blob $file_path"'
    fi
 
  ' \
  --tag-name-filter cat \
  -- --all

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎