Updated: 14 November 2025
Stash away the changes in a dirty working directory.
Also stash away un-tracked files
git stash --include-untracked
git stash -u
Freelance software engineer United Kingdom
Updated: 14 November 2025
Stash away the changes in a dirty working directory.
Also stash away un-tracked files
git stash --include-untracked
git stash -u
Updated: 01 January 2025
Merge our-branch but without fast forwarding
git merge --no-ff our-branch
Updated: 09 November 2025
Concurrently checkout multiple branches of the same repository.
Delete a worktree
git worktree remove worktree_name
List all worktrees
git worktree list
Create a worktree at path and checkout commit-ish into it
git worktree add <path> <commit-ish>
Updated: 07 October 2024
List files which were touched by a commit
git show --pretty="" --name-only REVISION
Show a file at a particular revision
git show REVISION:path/to/the/file
Updated: 16 June 2024
Initialize a repo with no working directory e.g. a shared repository. Developers can clone shared-project.git
git init --bare shared-project.git
Use a bare git repo to control a working-tree in another directory
git --work-tree=path/to/my-code --git-dir=path/to/bare-repo.git <usual git commands>
Updated: 30 May 2024
Push everything to a new remote
git push new-remote --all
git push new-remote --tags
# Also push remote branches to new-remote, even where local copies do not exist.
git push new-remote 'refs/remotes/origin/*:refs/heads/*'
Updated: 17 May 2024
Clone a single branch from a repository
git clone --branch xdebug2 https://github.com/xdebug/xdebug.org.git
Updated: 15 February 2024
Make a patch file from the 1st commit in HEAD
git diff @~1 @ > my.patch
Apply the patch file to another repo
git apply my.patch
Updated: 10 January 2025
Remove un-tracked directories and files from the working tree
git clean -fd
Remove un-tracked directories and files from the working tree. Also remove (-X) ignored files.
Can be combined with the -n/--dry-run option
git clean -fdX
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