Configuration
Once you’ve installed Git, you need to set it up so it works properly with your projects. This involves configuring a few important settings. Let’s walk through the basics.
Setting Up Git
Check Your Settings: You can see your current Git settings by using this command in your terminal or command prompt:
git config --list
- Set Your Name and Email: Git needs to know who you are to keep track of your work. You should set your name and email address, which will be used in your commits (changes you make to the code).
For everyone on your computer: Use these commands, replacing [firstname lastname] and [valid-email] with your own details:
git config --global user.name "[firstname lastname]" git config --global user.email "[valid-email]"
The --global option makes these settings apply to all of your Git projects.
For a specific project: If you want to use a different name or email for a specific project, go to that project’s folder and use the same commands without --global.
Setting Up Line Endings
Different operating systems handle text files a bit differently. You can set Git to handle these differences automatically.
For Linux or Mac: Use these commands to ensure your line endings are set up correctly:
git config --global core.autocrlf input git config --global core.safecrlf true
For Windows: Use these commands:
git config --global core.autocrlf true git config --global core.safecrlf true
What Do These Settings Do?
core.autocrlf: This setting helps Git manage line endings so they look the same on different operating systems.
core.safecrlf: This setting ensures that line ending changes won’t mess up your files.
With these settings in place, you’re ready to start using Git for your projects!