IchHabRecht

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

Jul 24th, 2016
356
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.40 KB | None | 0 0
  1. #!/bin/bash
  2. file_path=composer.json
  3. before_commit=$(git rev-parse --verify 5942ce7)
  4. file_blob=$(git hash-object -w "$file_path")
  5. git filter-branch \
  6.   --index-filter '
  7.  
  8.    if x=$(git rev-list -1 "$GIT_COMMIT" --not '"$before_commit"') &&
  9.       test -n "$x"; then
  10.         git update-index --add --cacheinfo 100644 '"$file_blob $file_path"'
  11.    fi
  12.  
  13.  ' \
  14.   --tag-name-filter cat \
  15.   -- --all
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment