forked from Shoray2002/practice-git
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c73035
commit 6ac7f1b
Showing
1 changed file
with
40 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Miscellaneous | ||
|
||
There some things that are good to know, but not strictly necessary. Here's an (incompplete) list of the ideas. Please feel free to add any 'life hacks' you know/discover to this! | ||
|
||
## Clone depth | ||
|
||
In old repos, there's ususally a lot of history. So, cloning them often takes many GBs, while the actual code you'd like to download(to, for example, browse around) is only a few dozen MBs. To get around this, we can use `git clone --depth 1`. For example, `git clone --depth 1 [email protected]:pytorch/pytorch.git` takes significantly less time than cloning the entire repo. | ||
|
||
## Aliases | ||
|
||
There are some commands that we use all the time(for example, `git status`). To avoid typing `status` every single time, we can tell git to interpret `git s` as `git status`. To do this, run | ||
|
||
```bash | ||
git config --global alias.s status | ||
``` | ||
|
||
You can replace `s` with anything other alias. The `--global` flag tells git that we want this setting to be applied everywhere. | ||
|
||
## gitconfig | ||
|
||
You can make a lot of tweaks to git to make it better. For example, if you misspell commands all the time, you can tell git to autocorrect you and run the command in a couple of seconds: | ||
|
||
```bash | ||
git config --global help.autoCorrect 50 | ||
``` | ||
|
||
This will autocorrect your commands(for example, from `git rebaes` to `git rebase`) in 5 seconds and run it. | ||
|
||
Some other common options are(thanks @Animeshz for these): | ||
|
||
```bash | ||
git config --global user.email <email> # set your default commit email | ||
git config --global user.name <full-name> # set your default commit name | ||
git config --global core.editor code # use vscode to edit commit messages etc | ||
git config --global core.editor vim # use vim to edit commit messages etc | ||
git config --global core.editor nano # use nano to edit commit messages etc | ||
|
||
``` | ||
|
||
A complete list of all configuration options can be found [here](https://git-scm.com/docs/git-config). |