Building error for firmware code not using git to download

Yesterday, I accidentally deleted px4 firmware code:cry::cry:
Because of poor network speed at my home, I downloaded the firmware code(including submodule code) somewhere else.
Then I put the code into a direactory: ~/px4/src/Firmware, and executed the command: make px4fmu-v2_default.
Error occured:

zyq@ubuntu:~/px4/src/Firmware$ make px4fmu-v2_default
PX4 CONFIG: /home/zyq/px4/src/Firmware/build_px4fmu-v2_default
REINITIALIZING GIT SUBMODULES
no git repo found in NuttX/.git
error: pathspec 'NuttX' did not match any file(s) known to git.
Did you forget to 'git add'?
REINITIALIZING GIT SUBMODULES
no git repo found in Tools/gencpp/.git
error: pathspec 'Tools/gencpp' did not match any file(s) known to git.
Did you forget to 'git add'?
REINITIALIZING GIT SUBMODULES
no git repo found in Tools/genmsg/.git
error: pathspec 'Tools/genmsg' did not match any file(s) known to git.
Did you forget to 'git add'?
REINITIALIZING GIT SUBMODULES
no git repo found in Tools/jMAVSim/.git
error: pathspec 'Tools/jMAVSim' did not match any file(s) known to git.
Did you forget to 'git add'?
REINITIALIZING GIT SUBMODULES
no git repo found in Tools/sitl_gazebo/.git
error: pathspec 'Tools/sitl_gazebo' did not match any file(s) known to git.
Did you forget to 'git add'?
REINITIALIZING GIT SUBMODULES
no git repo found in cmake/cmake_hexagon/.git
error: pathspec 'cmake/cmake_hexagon' did not match any file(s) known to git.
Did you forget to 'git add'?
REINITIALIZING GIT SUBMODULES
no git repo found in mavlink/include/mavlink/v1.0/.git
error: pathspec 'mavlink/include/mavlink/v1.0' did not match any file(s) known to git.
Did you forget to 'git add'?
REINITIALIZING GIT SUBMODULES
no git repo found in mavlink/include/mavlink/v2.0/.git
error: pathspec 'mavlink/include/mavlink/v2.0' did not match any file(s) known to git.
Did you forget to 'git add'?
REINITIALIZING GIT SUBMODULES
no git repo found in src/lib/DriverFramework/.git
error: pathspec 'src/lib/DriverFramework' did not match any file(s) known to git.
Did you forget to 'git add'?
REINITIALIZING GIT SUBMODULES
no git repo found in src/lib/DriverFramework/cmake/cmake_hexagon/.git
error: pathspec 'src/lib/DriverFramework/cmake/cmake_hexagon' did not match any file(s) known to git.
Did you forget to 'git add'?
REINITIALIZING GIT SUBMODULES
no git repo found in src/lib/DriverFramework/dspal/.git
error: pathspec 'src/lib/DriverFramework/dspal' did not match any file(s) known to git.
Did you forget to 'git add'?
REINITIALIZING GIT SUBMODULES
no git repo found in src/lib/ecl/.git
error: pathspec 'src/lib/ecl' did not match any file(s) known to git.
Did you forget to 'git add'?
REINITIALIZING GIT SUBMODULES
no git repo found in src/lib/matrix/.git
error: pathspec 'src/lib/matrix' did not match any file(s) known to git.
Did you forget to 'git add'?
REINITIALIZING GIT SUBMODULES
no git repo found in src/modules/uavcan/libuavcan/.git
error: pathspec 'src/modules/uavcan/libuavcan' did not match any file(s) known to git.
Did you forget to 'git add'?
REINITIALIZING GIT SUBMODULES
no git repo found in unittests/googletest/.git
error: pathspec 'unittests/googletest' did not match any file(s) known to git.
Did you forget to 'git add'?
REINITIALIZING GIT SUBMODULES
no git repo found in src/drivers/gps/devices/.git
error: pathspec 'src/drivers/gps/devices' did not match any file(s) known to git.
Did you forget to 'git add'?
-- nuttx-px4fmu-v2-default
-- CMAKE_INSTALL_PREFIX: /usr/local
-- cmake module path: /home/zyq/px4/src/Firmware/cmake
-- catkin DISABLED
-- Using C++03
-- Release build type: RelWithDebInfo
-- Adding UAVCAN STM32 platform driver
fatal: Not a valid object name HEAD
-- GIT_TAG = 
fatal: Needed a single revision
CMake Error at cmake/common/px4_base.cmake:937 (string):
  string sub-command SUBSTRING requires four arguments.
Call Stack (most recent call first):
  CMakeLists.txt:440 (px4_create_git_hash_header)


fatal: Not a valid object name HEAD
-- Configuring incomplete, errors occurred!
See also "/home/zyq/px4/src/Firmware/build_px4fmu-v2_default/CMakeFiles/CMakeOutput.log".
make[1]: *** [cmake_check_build_system] Error 1
make: *** [px4fmu-v2_default] Error 2

Could someone help me? Or I have to re-download the firmware locally?

Now, I re-downloaded the code, although time is long, this problem was avoided.