Skip to content

Commit

Permalink
doc(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 c80bf88
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://git@git.example.com/".insteadOf "https://git.example.com/"
git config --global url."ssh://git@github.com/".insteadOf "https://github.com/"
git config --global url."ssh://git@gitlab.com/".insteadOf "https://gitlab.com/"
git config --global url."ssh://git@bitbucket.com/".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://git@git.example.com/".insteadOf "https://git.example.com/"
git config --global url."ssh://git@git.example.com.com/".insteadOf "git@git.example.com.com:"

# GitHub
git config --global url."ssh://git@github.com/".insteadOf "https://github.com/"
git config --global url."ssh://git@github.com/".insteadOf "git@github.com:"

# GitLab
git config --global url."ssh://git@gitlab.com/".insteadOf "https://gitlab.com/"
git config --global url."ssh://git@gitlab.com/".insteadOf "git@gitlab.com:"

# BitBucket
git config --global url."ssh://git@bitbucket.com/".insteadOf "https://bitbucket.com/"
git config --global url."ssh://git@bitbucket.com/".insteadOf "git@bitbucket.com:"
```

### How to authenticate git with deploy tokens

Abbreviated from
Expand Down

0 comments on commit c80bf88

Please sign in to comment.