Skip to content
Snippets Groups Projects
Commit 245d4817 authored by Edu Almas's avatar Edu Almas
Browse files

Added "git tips" page to avoid problems when collaborating in groups with different OSes.

parent 982fa7db
No related branches found
No related tags found
No related merge requests found
Pipeline #278440 passed with warnings
# Tips when collaborating with git across different operating systems
!!! warning "Important"
configuring this before we start contributing to this repo will save us lots of headaches down the road
!!! info "tl;dr"
Different operating systems encode the "end of a line" in text files in different ways.
git supports them all, but we must configure each of our computers correctly, to avoid messing things up for other people in our team.
Checkout that you configured
your [git settings according to this guide](https://stackoverflow.com/questions/10418975/how-to-change-line-ending-settings)
before committing files in this repo.
## How to fix it
### Windows users
the git setting called 'core.autocrlf' should be set to 'true'
```bash
git config --global core.autocrlf true
```
### Linux/Mac/Unix users
the git setting called 'core.autocrlf' should be set to 'input'
```bash
git config --global core.autocrlf input
```
## So... What happens if I don't configure it correctly?
you will likely notice that LOTS of files appear to be modified, but when you go check out the differences, nothing
seems to be changed.
You will also notice it, if you see this output when you run `git diff`
```
$ git diff
warning: LF will be replaced by CRLF in README.md.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in cinder-superhero/404.html.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in cinder-superhero/base.html.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in cinder-superhero/content.html.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in cinder-superhero/css/base.css.
[...]
```
This isn't too bad until you consider the consequences: Since you are effectively changing each of the lines (the last
character of the line is the line ending), git will treat that line as "modified by you", if anyone else makes any
change, git will consider that "two people changed the same line" => bring up the "Merge conflict error".
The ultimate consequence of this is that the rest of the team will be carrying the burden of your misconfiguration.
!!! warning "This will result in lots more _merge conflicts_ than normal."
For more info, check out [the official doc](https://www.git-scm.com/book/en/v2/Customizing-Git-Git-Configuration)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment