Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Most engineers have Git aliases; what are yours? (will-keleher.com)
3 points by gcmeplz 11 months ago | hide | past | favorite | 7 comments


I have not used this in a while but here is an old function from /etc/profile.d/functions.sh on Alpine that I used to tame some unwieldy .git folders in the past. No idea if any of it has been deprecated. It's like one big monster alias. Nowadays I instead just clone a repo to a ramdisk, purge the .git folder and then rsync it to my hoarded stash of git repos.

    function gitgc()
    {
    git config --global core.compression 6
    git config --global core.loosecompression 6
    git config --global pack.compression 6
    git config --global core.autocrlf input
    git config --global alias.st status
    git config --global alias.ci commit
    git config --global alias.co checkout
    git config --global alias.br branch
    git config --global branch.autosetuprebase always
    git config --global pack.threads "2"
    git config --global pack.windowMemory "100m"
    git config --global pack.packSizeLimit "100m"
    export GIT_HTTP_MAX_REQUEST_BUFFER=100M
    git config --global ssh.postBuffer 1000000000
    git config --global http.postBuffer 1000000000
    # echo '*.zip -delta' > .gitattributes
    # echo '*.jpg -delta' >> .gitattributes
    # echo '*.bin binary -delta' >> .gitattributes
    git fsck --full --unreachable;
    git repack -a -d -F --depth=1 --window=10;
    git reflog expire --all --expire=now --expire-unreachable=now;
    git repack -a -d -F --depth=1 --window=10;
    git gc --prune=now --aggressive;
    git fsck --full --unreachable;
    }


> Nowadays I instead just clone a repo to a ramdisk, purge the .git folder and then rsync it to my hoarded stash of git repos.

You're probably already doing this, but if you do a shallow clone (git clone --depth=1 ..) you'll limit the amount that ends up in .git that you need to purge.

Even with shallow clones, I'm still surprised that it ends up with a .git that's a decent percentage of the total. I just tried it on a repo and ended up with 16% of the total size being .git. I would have guessed that it'd be much smaller than that.


I had also tried that but some repos still get fairly big and all I wanted was the code not the .git since I am not a proper developer. To your point they can still be quite large.

    cd /dev/shm/block && git clone -j4 --depth=1 --branch=master https://github.com/firehol/blocklist-ipsets.git

    du --max-depth 1 -hc
    24M ./ipip_country
    4.0M ./ipdeny_country
    9.6M ./ip2location_country
    6.9M ./geolite2_country
    25M ./.git
    140M .
    140M total
It's not awful but I currently keep up to date copies of about 300 git repos and if I keep all the big ones it can add up to several GB of data I do not need. For now I just clone to a ramdisk and whack the .git directory for several of the big ones before I rsync back to disk. I probably lose some interesting history doing that.


.bashrc:

  alias g='git'
.gitconfig:

Tons of aliases, but most often used are:

  a = add
  amend = commit --amend
  b = branch
  co = checkout
  po = pull origin
  fa = fetch --all
  reb = rebate
  reba = rebase --abort
  rebm = rebase master
  unstage = git rm --cached
As TFA demonstrates, it's also possible to alias full-blown shell commands and even multiple shell (or git) commands, which is powerful.

Someday I would like to give jj a real try, too.

https://github.com/jj-vcs/jj


  alias lg='lazygit'


> Most engineers

I don't believe that but I use https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git


Should probably say "most engineers I've worked with," but I think that's mostly a testament to the git workflows where I've worked (lots of small commits and short-lived branches).

Plus, once you pair with one person with snazzy aliases, it might make you want to make your own




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: