Setting up & Operating GIT repositories

Client Setup

identify yourself,

#git config --global --edit
git config user.name
git config user.name "your name or user@hostname"
git config user.email
git config user.email "your@email"

some defaults,

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

Basic usage

see the changed files

git log
git show COMMIT --stat

see all the diffs

#git log -p
git show COMMIT

Dirty Tweaks

for docs, scripts & configs you do not want to track like hell, those are some handy GIT aliases,

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

to push the devil even harder, one might use those Shell aliases,

alias push='git nc && git push'
alias stat='git diff --stat --cached origin/master'

Fetching a repository

Github,

git clone git@github.com:ACCOUNT/REPO.git
#git clone https://github.com/pbraun9/slackbuilds.git

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

Using GIT in production

update the list of branches, switch to the new revision,

    git fetch -a
    git checkout release-1.1.0
    git pull

and restart the application.

Troubleshooting

CAs

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

git config --global http.sslVerify true

Enabling RAW control chars

If you got shit like this when doing git diff,

ESC[32m+ESC[mESC[32m#

==> enable “raw” control characters in your PAGER,

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

Sharing 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

Resources

How to show what a commit did? https://stackoverflow.com/questions/1157818/how-to-show-what-a-commit-did

8.1 Customizing Git - Git Configuration https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#Basic-Client-Configuration

Show File Diffs When Viewing Git Log https://til.hashrocket.com/posts/8ii3emcrda-show-file-diffs-when-viewing-git-log

The Git Hater’s Guide http://www.evan.org/Fun/Git/index.htm

10 things I hate about Git https://stevebennett.me/2012/02/24/10-things-i-hate-about-git/

List Git aliases https://stackoverflow.com/questions/7066325/list-git-aliases

How to see the changes in a Git commit? https://stackoverflow.com/questions/17563726/how-to-see-the-changes-in-a-git-commit

git: can’t push (unpacker error) related to permission issues https://stackoverflow.com/questions/4025708/git-cant-push-unpacker-error-related-to-permission-issues


HOME | GUIDES | BENCHMARKS | html