-1

I have a .git repository and when a clone it, its not syncing. When i run "git branch", i'm receiving the branch "master", but that it's not sync when i make changes in the original project folder.

how can i sync the master branch in another directory?

My directory tree:

folder
 |_ Project
 |    |_ .git
 |
 |_ Another Folder 
 |    |_ Project
 |         |_ .git

commands that i runed:

PS c:Another Folder>: git clone "c:Project/.git"

1 Answers1

1

For cloning a remote (or local) repository, it must be setup as "bare". Without this initial condition you can't clone from it.

In order to clone from a local repository, you can use the following command: git clone --local {path-to-repo}. This will create a clone which you can use for regular git tasks (add, rebase, merge, push, etc.).

Note that you can also convert an existing regular (cloned) repository to a bare repository for cloning with git config --bool core.bare true.

EDIT:

As pointed out in the comment section (@LeGEC), you actually can clone from a non bare repo. However, you will not be able to issue git push commands on the checked out branch.

Jib
  • 1,334
  • 1
  • 2
  • 12
  • 2
    needs fixing: you can perfectly clone a non bare repo. The only limitation of using a non bare repo as a remote is that git will refuse to accept `git push` commands that would update the active branch of that repo -- e.g: if checked out branch in the non bare remote is `master`, you won't be able to run `git push` on the `master` branch from the clone. – LeGEC Jan 09 '23 at 20:00
  • 1
    @LeGEC Thanks for pointing that out, I updated the answer accordinlgly – Jib Jan 09 '23 at 20:28