Fix git related issues

1. Remove output from git command, some of the messages are useless, will confuse users.
2. Replace the command using 'foreach' with 'for' loop.
   'foreach' will stop the loop when error occured in one of the loop,
   In our usecase, we want continue the loop.