-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(git): update reasonable defaults
- Loading branch information
Showing
1 changed file
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 | ||
|