Score:0

is it possible to git clone from one local directory to another local directory on ubuntu

tc flag

I have created two directories on my local machine. One is named dev_projects and another is named git_projects. I have a project folder in git_projects. I wanted the project inside the git_projects directory to act as a remote git project so that I could git clone from this project to my dev_projects directory. I wanted to know if it is really possible.

This is the directory structure

dev_projects
    
git_projects
    some_project

Once I clone the project I further wished to use git pull and git push commands as well. For now, I tried to implement this by putting the local directory path as a replacement for the HTTPS link

git clone /home/nishant/git_projects/some_project ./

But it gives me an error

fatal: repository '/home/nishant/git_projects/some_project' does not exist
in flag
I’m not quite following. You want to have a Git repo in two locations; one for prod and the other for dev. Is this right?
pLumo avatar
in flag
You need to have a `git` server. But I think you should use branches ...
jp flag
Dan
@pLumo You don't actually need a git server. You are free to to clone from any type of remote, as long as the full URI is a git repository. It can be a local path, a remote server, or even a colleague's machine without any extra git configuration as long as you have access to that repository. (In fact, there's no such thing as a "git server". Things like GitLab, GitHub, etc. just give a UI and proper ssh/https configuration to access remote git repositories)
Score:1
tc flag

I'm sorry, I just realized my dumb mistake. Actually, I didn't convert my project to a git repo by initializing Git. That's why I wasn't able to use the git commands. If you want to use git clone on a local directory, it's not possible.

First, you have to covert the local directory into the local repository by initializing git inside that directory by running the git init command. In my case, I should have initialized git inside my some_project folder. Now git clone will work.

jp flag
Dan
In the first paragraph you say, "If you want to use git clone on a local directory, it's **not** possible." while in the second one you explain how it is actually possible (It is possible to clone a local directory as long as that directory is a Git repository).
Nishant Kumar avatar
tc flag
Yes, You're right Dan, maybe I should have framed it better but anyways you made it very obvious now.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.