Move branch to another laptop with remote repository

Viewed 97

I was working in a local branch and before sending the changes to the remote repository, the network card of the Microsoft machine broke down. Then I had to change to a Linux machine and when copying the project it tells me that everything has been modified (it must be the file system). How can I recover the project and upload only the changes made and not the entire project?

1 Answers

Copying over the entire Git folder from one machine to another should also move your project in the same state it was in originally. I suspect that the issue is that you moved from Windows to Linux, and now every file is showing up as changed due to the difference in line endings on those two OSs. Linux uses \n as the line ending, while Windows uses \r\n. First, try running the following command from Git on your Linux box:

git diff -w

If you see only changes in line endings, then you can be pretty sure that this is the reason why every file is showing up as being changed.

Here is one way you may tell Git to convert line endings to Windows CRLF automatically:

git config --global core.autocrlf true

This might work assuming that all your files have CRLF, having come from a Windows machine.

Related