Reputation: 7018
I am trying to copy a folder(.husky) from current path to parent folder:
#!/bin/bash
# Get parent folder:
parent_folder=$(cd ../ && pwd)
# Trying to copy folder called `".husky"` into parent folder:
cp .husky $parent_folder/test1
But I am getting error saying:
fatal: not a git repository (or any of the parent directories): .git
Screenshot:
Upvotes: 0
Views: 386
Reputation: 1328112
Regarding the parent folder, track first the current folder of your script, assuming .. is relative to where your script is:
DIR="$( cd "$( dirname "$(readlink "${BASH_SOURCE[0]}")" )" && pwd )"
parent_folder=$(cd "${DIR}" && pwd)
echo "parent_folder='${parent_folder}'"
Then add set -x
in the first lines of your script to see where it triggers the "not a git repository
" error message.
The OP kittu confirms in the comments:
Actually I had
git
alias setup previously wherecp
isalias cp='git commit -p'
, hence thegit
error.
Its working fine now.
Upvotes: 1