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
You can move a file to a different directory on GitHub or by using the command line. In addition to changing the file location, you can also update the contents of your file, or give it a new name in the same commit.
The default location that Git Bash starts in is typically the home directory (~) or /c/users/<Windows-user-account>/ on Windows OS. To determine the current directory, type pwd at the $ prompt. Change directory (cd) into the folder that you created for hosting the repository locally.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With