Git clone does not clone the specified remote repository

Recently, I have a strange behavior when trying to clone a remote repository to my local machine using git bash as it does not clone the specified remote repository but it clones one of my docker project repo. For example: I clone a remote repository using the command below:

Holyken@HolykenComputer MINGW64 /e/test_repo                                                                            
$ git clone https://github.com/LearningJournal/Kafka-Streams-Real-time-Stream-Processing.git                            
Cloning into 'Kafka-Streams-Real-time-Stream-Processing'...                                                             
remote: Enumerating objects: 26, done.                                                                                  
remote: Counting objects: 100% (26/26), done.                                                                           
remote: Compressing objects: 100% (25/25), done.                                                                        
remote: Total 26 (delta 0), reused 26 (delta 0), pack-reused 0 (from 0)                                                 
Receiving objects: 100% (26/26), 307.43 KiB | 881.00 KiB/s, done.

However, it cloned my docker project. I checked the remote repo and it returns 3 origin results and two of them point to the same repository of my docker project:

Holyken@HolykenComputer MINGW64 /e/test_repo                                                                            
$ cd Kafka-Streams-Real-time-Stream-Processing/   

Holyken@HolykenComputer MINGW64 /e/test_repo/Kafka-Streams-Real-time-Stream-Processing (master)                         
    $ git remote -v                                                                                                         
    origin  https://holykens:git_credentials@github.com/holykens/docker-react.git (fetch)          
    origin  https://holykens:git_credentials@github.com/holykens/docker-react.git (push)           
    origin  https://github.com/LearningJournal/Kafka-Streams-Real-time-Stream-Processing.git (push)

I tried to remove all the origin to clone again but it just removed the repo Kafka-Streams-Real-time-Stream-Processing and the origin pointing to my docker project still exists.

Holyken@HolykenComputer MINGW64 /e/test_repo/Kafka-Streams-Real-time-Stream-Processing (master)                         
$ git remote remove origin                                                                                                                                                                                                                      

Holyken@HolykenComputer MINGW64 /e/test_repo/Kafka-Streams-Real-time-Stream-Processing (master)                         
$ git remote -v                                                                                                         
origin  https://holykens:git_credentials@github.com/holykens/docker-react.git (fetch)          
origin  https://holykens:git_credentials@github.com/holykens/docker-react.git (push) 

How can I fix this issue to clone the repo Kafka-Streams-Real-time-Stream-Processing to my local machine ?

Thanks

The issue you’re encountering is due to multiple remotes with the same name (“origin”) pointing to different repositories in your local Git repository. Here’s how to fix it and clone the desired Kafka-Streams-Real-time-Stream-Processing repository:

1. Identify the Correct Remote:

  • Since you have three remotes with the name “origin”, you need to identify the one that points to the correct repository you want to clone (https://github.com/LearningJournal/Kafka-Streams-Real-time-Stream-Processing.git ).
  • Use the git remote -v command again to see the URLs associated with each “origin” remote:
    Bash
git remote -v

This will display the URLs for all remotes, including the ones with the same name.

2. Remove Unnecessary Remotes:

  • You can safely remove the remotes pointing to your docker project repository. Use the git remote remove <remote_name> command, replacing <remote_name> with the actual name of the remote you want to delete (e.g., “origin”):
    Bash
git remote remove origin  # Remove the first "origin" remote

3. Clone the Desired Repository:

  • Now that you’ve cleaned up the remotes, you can clone the Kafka-Streams-Real-time-Stream-Processing repository using the following command, specifying the full URL:
    Bash
git clone https://github.com/LearningJournal/Kafka-Streams-Real-time-Stream-Processing.git

This will clone the desired repository into a new directory named Kafka-Streams-Real-time-Stream-Processing within your current directory.

4. Renaming Remotes (Optional):

  • If you want to keep the “origin” name for the newly cloned repository, you can rename one of the remaining “origin” remotes:
    Bash
git remote rename <old_name> <new_name>  # Replace <old_name> and <new_name> with actual names

For example:

Bash

git remote rename origin-docker origin-old  # Renames the first "origin" to "origin-old"

By following these steps, you should be able to successfully clone the Kafka-Streams-Real-time-Stream-Processing repository and avoid conflicts with other repositories in your local Git environment.