There are some questions I find myself repeatedly searching for the answer for in Git. Below I'll capture those repeated questions and their answer! It will certainly help me, and I hope it will help you.
# The -m is the important part here! # I read the below as "git branch move to newname" git branch -m newname
# <base-branch> could be master, main, trunk, dev, feature/three/times/removed git rebase -i <base-branch>
Once your configured editor opens, you can change
squashto combine the commits. You could even
pickcommit to provide a nicer name before you open your PR.
git branch newbranch # Go back 3 commits. This could be any number. You *will* lose uncommitted work. # You can also specify a commit ref git reset --hard HEAD~3 git checkout newbranch
git fsck --cache --no-reflogs --lost-found --dangling HEAD # Then show the file git cat-file blob <SHA> > filename.txt
# Get list of unreachable files that git knows a file name for git fsck --unreachable --no-reflogs --no-cache HEAD | fgrep " tree " | cut -d " " -f3 | xargs -r -n1 git ls-tree | fgrep " blob " | cut -d " " -f 3- | sort -k2 -u