Search code examples
gitcore.autocrlf

git replace local branch with remote branch


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?


Solution

  • 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