Last active
December 4, 2023 13:16
-
-
Save emkis/7dc79f36d2759437c9b6e8c3756e6124 to your computer and use it in GitHub Desktop.
Node.js script (npx) to set all my Git configurations.
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
#!/usr/bin/env node | |
const shell = require('shelljs') | |
function setGitAlias({ name, command }) { | |
return shell.exec(`git config --global alias.${name} "!${command}"`) | |
} | |
shell.echo('💅 Setting git configurations...') | |
// User | |
shell.exec(`git config --global user.name "emkis"`) | |
shell.exec(`git config --global user.email "nicolasemkis@gmail.com"`) | |
// Core | |
shell.exec(`git config --global core.editor "nano"`) | |
// Alias | |
setGitAlias({ name: 'c', command: 'git checkout' }) | |
setGitAlias({ name: 'logg', command: 'git log --oneline' }) | |
setGitAlias({ name: 'statuss', command: 'git status --short' }) | |
setGitAlias({ name: 'alt-tab', command: 'git checkout -' }) | |
setGitAlias({ name: 'alt-tab-pull', command: 'git alt-tab && git pull' }) | |
setGitAlias({ name: 'rebase-main', command: 'git checkout main && git pull && git alt-tab && git rebase main' }) | |
setGitAlias({ name: 'add-branch', command: 'git checkout -b' }) | |
setGitAlias({ name: 'push-remote', command: 'git push origin -u' }) | |
setGitAlias({ name: 'delete-remote-tag', command: 'git push --delete origin' }) | |
setGitAlias({ name: 'delete-remote', command: 'git push origin -d' }) | |
setGitAlias({ name: 'undo-last-commit', command: 'git reset --soft HEAD~1' }) | |
shell.echo('✨ Done.') |
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
{ | |
"name": "emkis-git-configurations", | |
"version": "1.0.0", | |
"description": "Node.js script (npx) to set all my Git configurations", | |
"bin": "./git-configs.js", | |
"author": "Nicolas Jardim", | |
"license": "MIT", | |
"dependencies": { | |
"shelljs": "^0.8.5" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment