How do I fix the path of my local git repo after move?
previous local location: /C/website
new local location: /C/Projects/website
remote location: [email protected]:username/website.git
I moved my git repository from one folder /website
to another /projects/website
and now I get an error:
user@Thinkpad /C/Projects/website (master)
$ git push
fatal: 'C:/website' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Is there any way to fix this without having to re-clone the project? I tried:
$ git init
Reinitialized existing Git repository in c:/Projects/website/.git/
It that did nothing and I got the exact same error again when I tried to push.
Edit:
I ran: git config remote.origin.url C:/Projects/website
. Now when I commit after changing files I get the following reply:
user@Thinkpad /C/Projects/website (master)
$ git commit -m "added something"
[master e163ad9] added something
0 files changed
create mode 100644 something
user@Thinkpad /C/Projects/website (master)
$ git push
Everything up-to-date
Run git config -e
and change the address of the remote, to the correct remote location. In your case that will be url = [email protected]:username/website.git
This command will open for editing the .git/config
file of the repository.
(thanks to @Richard for the command)
Shortcut command:
git config remote.origin.url [email protected]:username/website.git