This is an old revision of the document!


Handy Git Commands

Collapse Commits Into One

Collapse last N commits into one.

git reset --soft HEAD~<n> && git add . & git commit -m <commit msg>

See Changes

Show names of files that changed between last commit and the working directory.

git diff --name-only HEAD

Show names of files that changed between the last two commits.

git diff --name-only HEAD HEAD~1

concise one-line log

git log --date=iso --pretty=format:"%h%x09%an%x09%ad%x09%s"

Orphaned/Unrelated Branches

  • Create an orphaned branch
  • Delete all the files in the new branch to start fresh
  • I think you have to at least do a commit to the branch before it can be pushed to a remote
git checkout --orphan <orphaned branch name to create>
git rm -rf .
git commit --allow-empty -m "Initial commit of an unrelated (orphan) branch"
git push -u origin <branch name>
  • handy_git_commands.1795120237.txt.gz
  • Last modified: 2026/11/19 20:30
  • by mgupton