4 ms·
What are the best practices for extending git? Every example seems to be a shells script that calls out to git; is there a better approach?
by ridiculous_fish 7y ago
What are the best practices for extending git? Every example seems to be a shells script that calls out to git; is there a better approach?
- saagarjha 7y agoWhat kind of functionality are you trying to add? For something simply, shelling out to git is probably OK; if you're writing something more complicated many projects rely on libgit2. For really weird stuff you can probably just directly go and edit objects inside of .git, as long as you're careful.
- ridiculous_fish 7y agoI would like to extend git such that you can check out a commit, amend it, rebase all descendants onto the amended commit, and update any branches accordingly. Effectively like `rebase -i` but not modal. This requires keeping some state around. libgit2 is a nice pointer, I'll check that out. (hg users will recognize this as "restacking.")
- pvinis 7y agoExtending how? Are you looking for automation or new commands or something else?
- bloopernova 7y agoYou can add a section called alias to your ~/.gitconfig [alias] lol = !git --no-pager log --graph --decorate --abbrev-commit --all --date=local --pretty=format:\"%C(auto)%h%d %C(blue)%an %C(green)%cd %C(red)%GG %C(reset)%s\" Then you can run "git lol" and get that cool output. That's one way to "extend" git.
- hnrodey 7y agogit aliases custom shell scripts use a Git library in your language of choice and write something
- emmelaich 7y agoYou can just put any executable in your PATH with name of git-WHATEVER. e.g. $ echo echo hello world > ~/bin/git-hello-world $ chmod +x !$ $ git hello-world hello world You'll even get typo recognition: $ git hello-worl git: 'hello-worl' is not a git command. See 'git --help'. The most similar command is hello-world