git branch | wc -lgit branch --merged | egrep -v "(^\*|master|main|dev)" | xargs git branch -dgit commit --amend --date="$(date -R)"This will trigger a git commit --amend action
git commit --amend --author="Puncoz Nepal <info@puncoz.com>"This will trigger a git commit --amend action
gcf This works on ZSH shell
git rev-list --count HEADgit rev-list --count <branch-name>git rev-list --count HEAD ^<branch-name>git rebase -i HEAD~5git rm -r --cached <file>
git add -ugit checkout <branch-name>or,
git switch <branch-name>git checkout <path-to-file>or,
git restore <path-to-file>For files
$ git clean -fFor Directories
$ git clean -dIf you are on the branch you want to rename:
git branch -m new-nameIf you are on a different branch:
git branch -m old-name new-namegit push origin :old-name new-nameSwitch to the branch and then:
git push origin -u new-namegit shortlog -s -n# Fetching all branches and tags from old repo
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
# Pushing into new repo with remote name new-repo
git push -u new-repo --all
git push -u new-repo --tagsfind . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatchgit add .gitignore
git commit -m "removed .DS_Store"git rev-parse HEAD
# or,
git rev-parse --verify HEADgit log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"%s" --no-mergesgit push --force-with-lease