0

I am working on a project locally on my machine. I want to have an up to date clone on my USB drive so I can hook it up to any other pc, clone it, and will be able to continue working on the project.

I initialised my local copy as a git repo and committed all my files. I then went to my USB drive and created an empty bare repository so this will server as the main remote repo.

What I would like to do next is to populte my USB (remote) repo with my existing project on my local machine. So if I want to go work from a different pc I can use my USB , clone it to the new PC and work from there.

I shall I solve this?

bcsta
  • 1,963
  • 3
  • 22
  • 61

1 Answers1

0

Let me understand the problem clearly. As I understand, you followed this steps:

  1. You have your local copy of a project (let's say in A folder).
  2. Then you initialized it as a git repo (by git init)
  3. then you committed it in your staging area (through the commit -m <message> command) and nothing else in folder A, right?
  4. Then, you created a new folder (let's call it B).
  5. You initialized the folder for git (with a new git init)
  6. Then you tried to clone the repo, right?

If so, I have some questions:

  • Which url did you use to make the clone (in step 6)?
  • Maybe you forgot to push the repository to a server (between step 3 and 4)
  • Let's assume that the previous points were already satisfied, you are trying to push an existing repository into another existing repository, thus it will never work without a merge operation!

If I understand well, you can act in this way by using a git server (e.g., github):

  • set a remote url in folder A through git remote add origin <url>
  • push the commit on the remote server (between point 3 and 4) through a git push operation
  • clone the pushed repository on your USB drive (in folder B), through a git clone <url> operation
t.montanaro
  • 123
  • 11
  • Until step 3. you are correct. I would then like to. have a USB remote repository as the main repo. so If I want to work on another machine I can do so with the USB. So in a way my USB would be my 'github'. Just updated the question to make it clearer – bcsta Feb 26 '19 at 17:28
  • Ok, now it is clear! You can follow the instructions provided here: [how-to-use-usb-drive-as-remote](https://stackoverflow.com/questions/43569757/how-to-use-usb-drive-as-remote) – t.montanaro Feb 26 '19 at 18:33