Skip to main content

Git Clone into a Non-Empty Directory

Powershell command to remove the existing .git folder

Remove-Item '.git' -Recurse -Force

Make a bare Git repository

git clone --bare [email protected]:devops/scripts.git .git

If true, this repository is assumed to be bare and has no working directory associated with it

git config --unset core.bare

Reset current HEAD to the specified state

git reset <option>

Options:

# History changed, HEAD changed, Working directory is not changed.
git reset --soft

# Wipe out all changes in the working tree, so that your current files match the contents of HEAD
git reset --hard

This will display the state of the working directory and the staging area.

git status

References:

  1. Difference between git reset soft, mixed and hard
  2. What's the difference between git reset --mixed, --soft, and --hard