For example, an alias that deletes local branches that have been merged in remote: ĭelete-local-merged = "!git fetch & git branch -merged | egrep -v 'master' | xargs git branch -d" You can also add other shell commands outside Git as aliases. Or in the terminal: git config -global alias.empty "git commit -allow-empty"Īnd you can use the command like this: git empty "Empty commit" In that case, you can add the following to the config file: Let's say you want to add an alias for adding an empty commit. For example, commits, stashing, and so on. In the Git configuration file, you can add aliases for those long commands you type from time to time. With this in place, pruning will occur whenever you do a git fetch. Or use the following command: git config -global fetch.prune true To do this, add the following to ~/.gitconfig: git directory when you do a git fetch -prune.Īs I explain in that article I just linked, you can automate this without always adding the -prune option. TLDR: Pruning during fetch is a cleanup method that deletes outdated remote references in your. Git pruning during fetchĭo you know what the pruning command does during fetch? If not, you may want to check this article first that covers how to delete outdated local branches with the prune git option and the branch delete command. This configuration tells Git that for operations like commits and tags, I want to use my VSCode editor.įor other types of editors, please refer to this image from Atlassian: Editor configurations for git from git config | Atlassian Git Tutorial 2. Or use this shell command: git config -global core.editor "code -wait" In your ~/.gitconfig file, add the following: This editor can be difficult to use, and if you're like me, you may want to use your preferred editor for writing commits. When you try to make commits in Git, it by default will open a vi editor that looks like this: Here are some global Git configuration tips. There are a lot more you can try after reading. The tips shared here are things that have worked for me. ![]() In this article, you'll learn some helpful Git configurations that can improve your development workflow. If no configurations are specified, Git uses its default settings. ![]() This file exists in the project level where Git is initialized ( /project/.git/config) or at the root level ( ~/.gitconfig). You can use the Git configuration file to customize how Git works.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |