Using GIT to get remote coce

I do not know from the online tutorial if I am properly establishing a connection with a git repository that is on a network.

All I have learned from a tutorial is how to set up a local repository, but getting data off of a network repository is knowledge I have yet to stumble upon or learn about and I wanted to save time by asking some online help forums.

I have just started using git after not using it for a while.
I have created a repository.
Then, as I was instructed, I made a “git clone” command which consisted of “git clone” followed by a path.
I expected this to get the contents of the path and put it into my repository – meaning the directory I made. This did not happen. What do I do?
How do I get a local copy of a remote work space for me to work on?

I am wondering if there is something like a “fetch” command I should be using.

The video tutorial I was looking at instructed how to make a local repository. But if I am trying to get code from a network location, how do I go about making that happen?

I was instructed at my job to run this command (copied here in pseudo code)

git clone blah-blah:/blah/git/noogie/dork_monkey/

and when I did this grom git-bash it did not produce any errors which led me to think it was the command I needed to do.

But I did this from the local directory that I used

git init

to set up as a locak repository.

I assumed that typiing a “git clone…” command would have copied all of the files on the blah-blah server over.

But it did not.

I wonder if all this might have something to do with the fact that I need to get my network up and running first.

In my File File Explorer window, when I click on the “This PC” icon on the left, I can see I have five Network locationis mapped to drive letters.

But when I click on the Network icon I get an error.

You can either:

  1. clone a remote repository; or
  2. init a local repository

You can’t (as far as I know) init a local repository first and then somehow clone a remote repository on top of that.

That should certainly be resolved first. No point trying to get something from the network if you can’t connect to it.

Why not ask someone at your job what to do?

It sounds like you need to clone the existing repo into a new directory and cherry pick your local changes over. As rpkamp pointed out you can’t clone into an existing directory. In that case the changes need to be cherry picked into the cloned directory. It’s important to follow the proper workflow from the beginning otherwise you will end up needing to cherry pick which isn’t always trivial. Cherry picking introduces significant risks to the project. If not done properly and with care you can easily overwrite and remove others code. Which is why it’s important to start from a cloned repo and not try to merge unversioned controlled locals into a version controlled project. I’ve had my code reverted before because people are cherry picking things into the same areas and files which I had recently merged. It’s like one of the most frustrating thing things to have your code reverted like that.

I assume the script was pasted into the Windows CMD Command Box?

Have you installed Git?

If and only if Git is installed then git will show brief instructions of the acceptable commands.

I use Linux and frequently clone from the following Repository:

Open the webpage and click on the green Code button to copy the following link, then try the following Windows CMD Prompt:

git clone https://github.com/codeigniter4/CodeIgniter4.git

Errors may be shown especially if the “CodeIgniter4” directory exists which will have to be deleted to download the latest Repository.

git fetch can only be used on a previously installed git branch

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.