How you can change the server URL for GIT repository

Assume that your remote origin (repository server URL) is:  and you want to replace it with .

Command to check your current origins:

You will be able to see the origins for both fetch and push operations:

Command to change the GIT repository origin:

That’s it. You now successfully relocated your repository pointing to the new server.

How to restore the deleted local file from GIT repository

It is very simple to get the locally deleted file in a git repository. Make sure that you are not committed any changes.

Suppose you deleted the file: myfolder/my_deleted_file.txt  accidentally and you want to retrieve the file from the server.

Execute the following command:

That’s it. Your file is now restored to the folder.

How to copy file from an SSH server to the local computer

On Linux systems, it is very easy to copy the files from one computer to another with the secure copy protocol.

Suppose you are logged into the server with SSH and you want to copy the file: /home/user/dummy.txt from the current server folder to your local path: /var/dummy.txt


Do the following steps:

  1. Exit from the ssh connection.
  2. Make sure that you are logged into your local machine.
  3. Execute the following command with the remote computer’s username and host name:
  4. You will be prompted for the password to connect with the server. Type the password to execute the secure copy operation.
  5. Your file from the remote server is now copied successfully to the local system. Make sure that the file is copied at the location /var/dummy.txt.