0

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:[email protected]/holykens/docker-react.git (fetch)          
    origin  https://holykens:[email protected]/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:[email protected]/holykens/docker-react.git (fetch)          
origin  https://holykens:[email protected]/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

4
  • 1
    Please do not include github credentials in a public question Commented Sep 5, 2024 at 3:49
  • 1
    Do you have a git repo in /e/test_repo? You cannot clone another repository inside it (or well, you can, but you will see weird things such as this happening). Commented Sep 5, 2024 at 4:19
  • 1
    Also, your GitHub personal access token is now compromised, remember to revoke it from GitHub settings and create a new one. In the future, do not put the credentials directly to remote URL, use credential helper. Commented Sep 5, 2024 at 4:20
  • Thank you, I removed the exposed PAT. I was not aware that is the credentials. Commented Sep 5, 2024 at 16:10

1 Answer 1

0

Did you try:

git remote set-url origin git://new.url.here

It was referenced in this issue:

How to remove remote origin from a Git repository

The idea is to set origin to a different value.

Sign up to request clarification or add additional context in comments.

2 Comments

Yeah, I checked on that solution as well but it did not resolve the issue
Try adding the main URL under a different name than origin. Something like: git remote set-url temporary git://new.url.here Then try to remove origin. It's possible it won't let you remove them because there are no other remote URLs to clone from if you removed them all. So make the "temporary" origin your base URL, delete the "origin" origin, and set the "origin" origin to your base URL, and delete the "temporary" origin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.