git instaweb

Updated: 22 October 2023

Instantly browse your working repository in gitweb. A simple script to set up gitweb and a web server for browsing the local repository.

By default, instaweb will look for the lighttpd web-server, see https://christaylordeveloper.co.uk/web-server/lighttpd.

You will need to install gitweb first

sudo apt install gitweb

Run the instaweb script

git instaweb --start

Browse to http://127.0.0.1:1234/

Stop instaweb

git instaweb --stop

git bisect

Updated: 27 August 2023

Start a bisect session

git bisect start

Pass git a commit where the problem is apparent

git bisect bad HEAD

and a good commit, sometime earlier

git bisect good fcd61994

Inspect / test the code, then inform git

git bisect good # or
git bisect bad

Finish the session

git bisect reset

git checkout

Updated: 21 September 2025

Create local branch with same name as remote one, directly establishing a tracking relationship

git checkout --track remote_name/branch_wanted_locally

Checkout a single file from a specific commit

git checkout commit-hash path/to/the/file

Checkout file(s), as it was at a particular commit

git checkout commit-hash -- my/file another/file2

Checkout directory from another branch

git checkout another-branch -- the-dir/

Checkout one file from another branch

git checkout grab-from-this-branch -- logout.js

git search

Updated: 06 July 2023

Search the text (case insensitive) of commit messages in all branches

git log --all -i --grep='text to find'

git config

Updated: 27 December 2025

https://git-scm.com/docs/git-config


Username and email

git config --global user.name "John Doe"
git config --global user.email "who@ever.cloud"

Colours

git config --global color.status.updated magenta
git config --global color.status.untracked magenta
git config --global color.diff.old magenta

Set vim as default editor

git config --global core.editor "vim"

Temporarily switch to another ssh private key

git --config "core.sshCommand=ssh -i /home/mruser/.ssh/id_rsa" fetch

Default to git merge --no-ff branch_name

git config --global merge.ff no

git rebase

Updated: 24 February 2026

Rebase a branch without first checking it out

git rebase this-branch on-this-branch

Rebase onto

git rebase --onto newbase from-commit-after branch-to-move

If required to squash into the first commit of a repository

git rebase --interactive --root