Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I fix the path of my local git repo after move?

Tags:

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 
like image 538
Whitecat Avatar asked Jan 22 '13 18:01

Whitecat


People also ask

Can I move local Git folder?

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.

Where is my Git repository path?

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.


1 Answers

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 
like image 200
fge Avatar answered Oct 18 '22 13:10

fge