handy_git_commands

Handy Git Commands

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.txt
  • Last modified: 2024/12/04 14:57
  • by mgupton