Skip to content

Instantly share code, notes, and snippets.

@mortalius
Last active July 1, 2021 09:59
Show Gist options
  • Save mortalius/0260da8b210c0ed540065e7fadbe7c2e to your computer and use it in GitHub Desktop.
Save mortalius/0260da8b210c0ed540065e7fadbe7c2e to your computer and use it in GitHub Desktop.

Setting branch tracking

When publishing local branch

git push -u origin dev

When checkouting

git checkout --track origin/dev

When forgot to do above

git branch -u origin/dev

Enable fetch for all branches

$ git config --get remote.origin.fetch
+refs/heads/master:refs/remotes/origin/master
As you can see, in my case, the remote was set to fetch the master branch specifically and only. I fixed it as per below, including the second command to check the results.

$ git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
$ git config --get remote.origin.fetch
+refs/heads/*:refs/remotes/origin/*

Find/identify large commits in git history?

(https://stackoverflow.com/a/42544963)

git rev-list --objects --all \
| git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
| sed -n 's/^blob //p' \
| sort --numeric-sort --key=2 \
| cut -c 1-12,41- \
| $(command -v gnumfmt || echo numfmt) --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment