lazygit "My commit msg"
function lazygit() {
git add .
git commit -a -m "$1"
git push
}
How do I reduce the pack file size?
rm -rf ./.git/
git init
git push --mirror [url-to-repo]
Delete the last commit, if it hasn't been pushed.
git reset --soft HEAD~1
Delete the last commit, if it has been pushed.
git reset --hard HEAD~1
git push origin HEAD --force
Temporarily ignore local changes to a file
git update-index --assume-unchanged <file>
Create a new branch
git branch <branch>
Delete an existing, local branch
git branch -D <branch>
Push a local branch
git push origin <branch>
Checkout a local copy of a remote branch
git checkout -b <local-branch> origin/<remote-branch>
Delete an existing, remote branch
git push origin --delete <branch>
Delete all stashes
git stash clear
Clean up references to obsolete branches
git remote prune origin; git gc --prune --aggressive
#!! DANGER !! Completely remove a file from git history (per branch) -- /usr/bin/true on osx, /bin/true on linux
git filter-branch -f --force --index-filter 'git rm -rf --cached --ignore-unmatch path/somefile' --prune-empty --tag-name-filter cat -- --all
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now
git push origin <branch> --force
#!! DANGER !! Remove history for a password/secret string for a specific file (per branch) -- /usr/bin/true on osx, /bin/true on linux
git filter-branch --force --tree-filter "[ -f <path>/<somefile> ] && sed -i 's/<super secrect password>//g' <path>/<somefile> || /usr/bin/true" -- --all
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now
git push origin <branch> --force