Live data from Hacker News

ToolGit: A collection of scripts that extend Git with various sub-commands

github.com

11–20 of 59 posts

Re: ToolGit: A collection of scripts that extend Git with various sub-commands

#11
post #8

This needs a “git-track”. Make the current branch track the one in origin with the same name, if it exists

In oh-my-zsh you have `ggsup` which is an alias for `git branch --set-upstream-to=origin/$(git_current_branch)`. `git_current_branch` is also a function that is bundled with oh my zsh.

Re: ToolGit: A collection of scripts that extend Git with various sub-commands

#12

"git-delete-gone-branches" is exactly what I've been needing, will give it a try soon!

"git delete gone branches" is a one liner that you can google. first stack overflow result gives you the answer:

    git remote prune origin
Why would you use this 50 line script to do the same?

Re: ToolGit: A collection of scripts that extend Git with various sub-commands

#13
Some of my git aliases might be useful to folks here (I post them from time to time on git threads)

Time to share my gitconfig aliases again :D

  lol = !git --no-pager log --graph --decorate --abbrev-commit --all --date=local -25 --pretty=short
  sw = !git checkout $(git branch -a --format '%(refname:short)' | sed 's~origin/~~' | sort | uniq | fzf)
  lc = !git rev-parse HEAD
  rb = !git for-each-ref --sort=-committerdate refs/heads/ --format='%(refname:short) %(objectname:short) %(committerdate:format:%F)' | column -t
  fza = "!git ls-files -m -o --exclude-standard | fzf -m --print0 | xargs -0 git add"
  gone = "!f() { git fetch --all --prune; git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D; }; f"
  root = rev-parse --show-toplevel
  oldest-ancestor = !zsh -c 'diff -u 
Some of these I don't use much, but others I use every day:

"git fza" (aliased to "ga") shows all unstaged files in fzf and you can use space to toggle them, then hitting enter finishes adding/staging them. This is great for selecting some files to stage. I use this one every day, it makes my workflow just a little better :)

"git gone" deletes local branches that don't exist in the remote. I just saw in this thread that git remote prune origin might do the same thing, I need to test that.

"git lol" is a log alias.

"git oldest-ancestor brancha branchb" does what it says.

"git root" is part of an alias "gr" which runs "cd $(git root)". That takes you to the project root, and "cd -" will take you back to your previous location.

"git dlog" shows a detailed commit log.

"git lc" just shows the last commit.

"git rb" shows recent branches. Piping it to "| sort -k3" will sort by date. (I really need to update that!)

"git sw" shows branches in fzf, hit enter on one and you checkout that branch.

Re: ToolGit: A collection of scripts that extend Git with various sub-commands

#14
These should be aliases in your git config.

    git config --global alias. 
I'm really trying to understand, and not to be too negative. I get coming up with a solution to a problem, and finding it neat locally. But before posting to HN, one might realize that these solutions that git provides existing tools for is better than maintaining this.

I'm also confused by all the comments just blindly commenting in the affirmative or providing suggestions. Are we all bots?

Re: ToolGit: A collection of scripts that extend Git with various sub-commands

#15

Some of my git aliases might be useful to folks here (I post them from time to time on git threads) Time to share my gitconfig aliases again :D lol = !git --no-pager log --graph --decorate --abbrev-commit --all --date=local -25 --pretty=short sw = !git checkout $(git branch -a --format '%(refname:short)' | sed 's~origin/~~' | sort | uniq | fzf) lc = !git rev-parse HEAD rb = !git for-each-ref --sort=-committerdate ref…

If you use oh-my-zsh's git plugin, it defines a huge number of aliases that minimize the characters you have to type in. I use these mostly every day:

  gl = git pull
  gp = git push
  ga = aliased to git fza from my above comment
  gc = "git commit -m " so I type 'gc "chore: commit message"'
  gd = git diff
  gs = git status
  gr = cd's to the top level of the repo, cd - returns to your previous position.
I had to override some of the oh-my-zsh defaults in my .zshrc:

  unalias gcd
  unalias ga
  unalias grep
  unalias gr
  unalias gc

  alias m='mise'
  alias fd='fd -HI'
  alias gfv='git fetch --verbose'
  alias gs='git status'
  alias gr='cd $(git rev-parse --show-toplevel)'
  alias ga='git fza' # depends on gitconfig containing the alias "fza"
  alias gc='git commit -m' # depends on "unalias gc"
  alias commit-types='cat $HOME/.local/dotfiles/commit-types.txt'
  alias ct='cat $HOME/.local/dotfiles/commit-types.txt'
  alias mcdd='mcd $(date "+%Y-%m-%d")'
  alias sp='showpath' # showpath = echo $PATH | sed -e $'s/:/\\\n/g'
  alias uuidgen='uuidgen | tr "[:upper:]" "[:lower:]"'
I hope these are useful to someone at some point!

Re: ToolGit: A collection of scripts that extend Git with various sub-commands

#16
post #14

These should be aliases in your git config. git config --global alias. I'm really trying to understand, and not to be too negative. I get coming up with a solution to a problem, and finding it neat locally. But before posting to HN, one might realize that these solutions that git provides existing tools for is better than maintaining this. I'm also confused by all the comments just blindly commenting in the affirmati…

If I see a git thread, I tend to semi-spam my git aliases because so few people realize that they can customize git's command line behaviour.

Re: ToolGit: A collection of scripts that extend Git with various sub-commands

#17

https://gist.github.com/romainl/a3ddb1d08764b93183260f8cdf0f... This script in your path means that after you say pull code and have merge conflicts, "git jump" will open vim with the quickfix list populated with the locations of the conflicts.

Jump is distributed under /usr/share/git-core/contrib or something.

Re: ToolGit: A collection of scripts that extend Git with various sub-commands

#18
post #14

These should be aliases in your git config. git config --global alias. I'm really trying to understand, and not to be too negative. I get coming up with a solution to a problem, and finding it neat locally. But before posting to HN, one might realize that these solutions that git provides existing tools for is better than maintaining this. I'm also confused by all the comments just blindly commenting in the affirmati…

If I see a git thread, I tend to semi-spam my git aliases because so few people realize that they can customize git's command line behaviour.

Yeah I am just finding it hard to believe that there are so many people who don't.

Maybe we are 10x engineers w.r.t. git aliases. Congratulations

Re: ToolGit: A collection of scripts that extend Git with various sub-commands

#19

Some of my git aliases might be useful to folks here (I post them from time to time on git threads) Time to share my gitconfig aliases again :D lol = !git --no-pager log --graph --decorate --abbrev-commit --all --date=local -25 --pretty=short sw = !git checkout $(git branch -a --format '%(refname:short)' | sed 's~origin/~~' | sort | uniq | fzf) lc = !git rev-parse HEAD rb = !git for-each-ref --sort=-committerdate ref…

If you use oh-my-zsh's git plugin, it defines a huge number of aliases that minimize the characters you have to type in. I use these mostly every day: gl = git pull gp = git push ga = aliased to git fza from my above comment gc = "git commit -m " so I type 'gc "chore: commit message"' gd = git diff gs = git status gr = cd's to the top level of the repo, cd - returns to your previous position. I had to override some o…

If you really want to minimize typing, try Emacs + Magit.

Re: ToolGit: A collection of scripts that extend Git with various sub-commands

#20
post #19

Earlier quoted context omitted.

If you use oh-my-zsh's git plugin, it defines a huge number of aliases that minimize the characters you have to type in. I use these mostly every day: gl = git pull gp = git push ga = aliased to git fza from my above comment gc = "git commit -m " so I type 'gc "chore: commit message"' gd = git diff gs = git status gr = cd's to the top level of the repo, cd - returns to your previous position. I had to override some o…

If you really want to minimize typing, try Emacs + Magit.

I should, I use Emacs a bunch, but I guess it's just muscle memory now to flip to the terminal.
Post reply on HN