Skip to content

Commit

Permalink
feat(git): update reasonable defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
coolaj86 committed Sep 14, 2024
1 parent 4628cc0 commit 05ba33d
Showing 1 changed file with 46 additions and 2 deletions.
48 changes: 46 additions & 2 deletions git/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ is a good place to get started if you're new to git.
- Files
- Commit Files
- Ignore Files
- Reasonable Defaults
- Create Branch
- Rebase by Default
- Rebase
- Auth via SSH
- Auth via Token

### Files
Expand Down Expand Up @@ -66,7 +67,30 @@ This will branch from the branch you're currently on.
git switch -c my-branch-name
```

### How to rebase by default
### What to set as Reasonable Defaults

To always use SSH keys, even when you clone the HTTPS url:

```sh
git config --global url."ssh://[email protected]/".insteadOf "https://git.example.com/"
git config --global url."ssh://[email protected]/".insteadOf "https://github.com/"
git config --global url."ssh://[email protected]/".insteadOf "https://gitlab.com/"
git config --global url."ssh://[email protected]/".insteadOf "https://bitbucket.com/"
```

To automatically create feature branches on push:

```sh
git config --global push.autoSetupRemote true
```

To automatically stash and unstash uncommitted changes before and after rebase:

```sh
git config --global rebase.autoStash true
```

To rebase by default:

```sh
git config --global pull.rebase true
Expand Down Expand Up @@ -102,6 +126,26 @@ git add ./my-merged-file
git rebase --continue
```

### How to authenticate git with SSH keys by default

```sh
# Git, Gitea, etc
git config --global url."ssh://[email protected]/".insteadOf "https://git.example.com/"
git config --global url."ssh://[email protected]/".insteadOf "[email protected]:"

# GitHub
git config --global url."ssh://[email protected]/".insteadOf "https://github.com/"
git config --global url."ssh://[email protected]/".insteadOf "[email protected]:"

# GitLab
git config --global url."ssh://[email protected]/".insteadOf "https://gitlab.com/"
git config --global url."ssh://[email protected]/".insteadOf "[email protected]:"

# BitBucket
git config --global url."ssh://[email protected]/".insteadOf "https://bitbucket.com/"
git config --global url."ssh://[email protected]/".insteadOf "[email protected]:"
```

### How to authenticate git with deploy tokens

Abbreviated from
Expand Down

0 comments on commit 05ba33d

Please sign in to comment.