Created
January 1, 2025 13:41
-
-
Save aasadi1978/fc57cd80e642b5b6b0efd49d12b9b1fb to your computer and use it in GitHub Desktop.
Setup Git global params
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://chatgpt.com/share/677545c9-65c8-8003-a0b6-06c432728abc | |
To set up the global parameters for your local Git repository, follow these steps: | |
### 1. **Set Global Username and Email** | |
These are used to identify the author of commits. | |
```bash | |
git config --global user.name "Your Name" | |
git config --global user.email "[email protected]" | |
``` | |
Verify the setup: | |
```bash | |
git config --global --list | |
``` | |
### 2. **Set Default Editor (Optional)** | |
Choose the editor Git will use for commit messages. For example: | |
- For VS Code: | |
```bash | |
git config --global core.editor "code --wait" | |
``` | |
- For Vim: | |
```bash | |
git config --global core.editor "vim" | |
``` | |
### 3. **Set Line Ending Preferences (Optional)** | |
This is especially useful for cross-platform projects: | |
- For Windows: | |
```bash | |
git config --global core.autocrlf true | |
``` | |
- For macOS/Linux: | |
```bash | |
git config --global core.autocrlf input | |
``` | |
### 4. **Set Default Branch Name** | |
Starting with Git 2.28, you can specify the default branch name for new repositories. | |
```bash | |
git config --global init.defaultBranch main | |
``` | |
### 5. **Set Credential Helper (Optional)** | |
If you want Git to remember your credentials: | |
- For macOS: | |
```bash | |
git config --global credential.helper osxkeychain | |
``` | |
- For Windows: | |
```bash | |
git config --global credential.helper wincred | |
``` | |
- For Linux: | |
```bash | |
git config --global credential.helper cache | |
``` | |
### 6. **Set Git Ignore Case Sensitivity** | |
Make Git ignore file name case changes: | |
```bash | |
git config --global core.ignorecase true | |
``` | |
### 7. **Set Pull Behavior** | |
Decide how Git behaves during `git pull`: | |
- Use rebase instead of merge (common for keeping history clean): | |
```bash | |
git config --global pull.rebase true | |
``` | |
### 8. **Global Configuration File** | |
Your global settings are stored in the `~/.gitconfig` file (Linux/macOS) or `%USERPROFILE%\.gitconfig` (Windows). You can manually edit this file if needed. | |
Check your full global configuration with: | |
```bash | |
git config --list --show-origin | |
``` | |
After these steps, your global Git parameters will be set up. Let me know if you need help with specific settings! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment