0

I have set the property "core.autocrlf" to "input" so that CRLF line endings are replaced by LF ones on commit. How can I replace the local branch in git with the remote branch so that all files in the local git repository have the line ending LF as in the remote branch?

Chris
  • 89
  • 1
  • 10

2 Answers2

1

I'm going to break this into two parts:

First:

How can I replace the local branch in git with the remote branch?

git checkout your-branch git fetch git reset --hard origin/your-branch will force the local branch to "look" exactly like the remote.

Second:

so that all files in the local git repository have the line ending LF as in the remote branch?

Without actually knowing your repository's history and what config changes you did it's hard to tell if the commands above will have the desired effect.

jcm
  • 1,752
  • 15
  • 27
0

Local and remote branches have the same commits, you can not chose one to checkout from.

If you had the core.autocrlf setting from the beginning, the commits have files with LF endings. To checkout and replace all files in your workspace with the newest commit use git reset with option --hard:

$ git reset HEAD --hard
Ozan
  • 4,235
  • 2
  • 20
  • 35