Assume that your remote origin (repository server URL) is: email@example.com/repository-name.gitÂ and you want to replace it with firstname.lastname@example.org/repository-name.gitÂ .
Command to check your current origins:
You will be able to see the origins for both fetch and push operations:
origin email@example.com/repository-name.git (fetch)
origin firstname.lastname@example.org/repository-name.git (push)
Command to change the GIT repository origin:
git remote set-url origin email@example.com/repository-name.git
That’s it. You now successfully relocated your repository pointing to the new server.
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:
git checkout myfolder/my_deleted_file.txt
That’s it. Your file is now restored to the folder.
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:
- Exit from the ssh connection.
- Make sure that you are logged into your local machine.
- Execute the following command withÂ the remote computer’s username and host name:
scp username@hostname:/home/user/dummy.txt /var/dummy.txt
- You will be promptedÂ for the password to connect with the server. Type the password to execute the secure copy operation.
- 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.