0

I created a git repository in folder A. And then, I push it to a remote (let's say it's called D) Then, I delete folder A, and create a new folder B with very different files/folders inside it. And, I want to change the remote D so it's pointing to B.

How to do it? thanks

phd
  • 82,685
  • 13
  • 120
  • 165
Terry Djony
  • 1,975
  • 4
  • 23
  • 41
  • 3
    A force push?­­­ – iBug Dec 25 '18 at 06:07
  • Possible duplicate of [How do I properly force a Git push?](https://stackoverflow.com/questions/5509543/how-do-i-properly-force-a-git-push) – phd Dec 25 '18 at 10:31
  • https://stackoverflow.com/search?q=%5Bgit-push%5D+how+to+force+push – phd Dec 25 '18 at 10:31
  • @iBug Sorry I'm not familiar with the term.. This question sounds more friendly to beginner, so I think it's better not to close it. – Terry Djony Dec 26 '18 at 02:41

1 Answers1

1
  1. Initialize a new git repository in B: git init
  2. Add all files in B: git add .
  3. Commit: git commit -a -m "Initial commit"
  4. Add D as a remote git remote add origin <D>
  5. Force push to D: git push -fu origin master

This will destroy the history on D, so beware and if some one else is referring to that remote it might piss them off.

Learath2
  • 20,023
  • 2
  • 20
  • 30