Setting up & Operating GIT repositories

Client Setup

identify yourself

#git config --global --edit
git config "your name"
git config "your@email"

git config
git config

define some better defaults

git config --global pull.ff only

#git config --global push.default simple
#git config --global core.editor elvis

Basic usage

see the last commit diff

git log --patch -1

see past commit changes and diff

git log
git show COMMIT --stat

see what’s been staged for commit already

git diff --cached --stat
git diff --cached
git status -v

Dirty speed-up tweaks

for text or html files, eventually avoid comments

git config --global 'commit -a --allow-empty-message -m ""'
git config --global 'commit --allow-empty-message -m ""'
git config --get-regexp alias

–or– directly use the shell aliases for that matter

alias push='git commit -a --allow-empty-message -m "" && git push'
alias commit='git commit --allow-empty-message -m ""'
alias stat='git diff --stat --cached origin/master'

Fetching a repository


git clone
#git clone

Gitlab on-premises

git clone ssh://git@gitsrv/home/git/project.git
#git clone http://git@gitsrv/home/git/project.git
#git clone https://git@gitsrv/home/git/project.git

GIT in production

update the list of branches and switch to the new revision

    git fetch -a
    git checkout release-1.1.0
    git pull

and restart the application



don’t forget to define your trust store, you need to do that manually on NetBSD

git config --global http.sslVerify true

raw control chars

when doing git diff


==> either find out where on earth the default behavior for less got changed (some old slackware release doing -M?… –or– enable “raw” control characters in your PAGER

git config --global core.pager "less -r"

share a repo across the file-system

If you need to share a repo with another user, using group permissions as such

#homedir does not need to be writable, but executable
chmod 750 /home/gollum/
cd /home/gollum/

#now making the repo writable for the group
chown -R gollum:gollum pub.git/
find pub.git/ -type d -exec chmod 770 {} \;
find pub.git/ -type f -exec chmod 660 {} \;
find pub.git/ ! -type d ! -type f

you need to fsck/prune/repack/fsck after changing perms. The link (see below) even says you need to do it on both sides, local and remote.

git fsck
git prune
git repack
git fsck


How to show what a commit did?

8.1 Customizing Git - Git Configuration

Show File Diffs When Viewing Git Log

The Git Hater’s Guide

10 things I hate about Git

List Git aliases

How to see the changes in a Git commit?

git: can’t push (unpacker error) related to permission issues


Why use –ff-only over –rebase


fetch in git doesn’t get all branches

How do I show the changes which have been staged?

git-diff - Show changes between commits, commit and working tree, etc

Git - deleted some files locally, how do I get them from a remote repository

Exploring History

2.3 Git Basics - Viewing the Commit History

How To Switch Branch on Git

Copyright © 2022 Pierre-Philipp Braun