git add . && git commit --amend --no-edit
git reset --hard HEAD~1
git push origin HEAD --force
git log --all --grep='<STRING>'
When publishing:
git push -u <REMOTE> <BRANCH_NAME>
After publishing:
git branch -u <REMOTE>/<BRANCH>
git branch --merged| egrep -v "(^\*|master|main|dev)"
# GIT
alias ga='git add'
alias gaa='git add .'
alias gau='git add --update'
alias gb='git branch'
alias gbd='git branch --delete '
alias gc='git commit'
alias gcm='git commit --message'
alias gcf='git commit --fixup'
alias gco='git checkout'
alias gcob='git checkout -b'
alias gcom='git checkout master'
alias gcos='git checkout staging'
alias gcod='git checkout develop'
alias gd='git diff'
alias gda='git diff HEAD'
alias glg='git log --graph --oneline --decorate --all'
alias gld='git log --pretty=format:"%h %ad %s" --date=short --all'
alias gm='git merge --no-ff'
alias gma='git merge --abort'
alias gmc='git merge --continue'
alias gnit='git init'
alias gp='git push'
alias gpl='git pull'
alias gpom="git push origin master"
alias gpr='git pull --rebase'
alias gr='git rebase'
alias gs='git status'
alias gss='git status --short'
alias gst='git stash'
alias gsta='git stash apply'
alias gstd='git stash drop'
alias gstl='git stash list'
alias gstp='git stash pop'
alias gsts='git stash save'
git config --global core.sshCommand C:\\Windows\\System32\\OpenSSH\\ssh.exe
System-wide .gitconfig
autocrlf=false
Per-user solution
git config --global core.autocrlf false
Per-project solution
git config --local core.autocrlf false
git branch -vv | grep gone | awk '{print $1}' | xargs git branch -D
git branch -D $(git branch --merged| egrep -v "(^\*|master|main)")
git branch -D `git branch | grep -E '^3\.2\..*'`
git fetch --prune
git remote prune origin <--dry-run>
You should do this before you push:
for remote in `git branch -r | grep -v master `; do git checkout --track $remote ; done
Followed by
git push --all
find . -name ".DS_Store" -print0 |xargs -0 git rm --ignore-unmatch
git checkout master
git pull origin master
git checkout feature-branch
git rebase master
git push --force-with-lease origin feature-branch
git update-index --assume-unchanged content/uploads
git config --global tag.sort version:refname
git shortlog $(git tag | tail -n 1)..HEAD
git tag -a v1.4 -m "my version 1.4"
After a shallow clone, get all branches with:
git remote set-branches origin '*'
git show --name-only c7c82a6c -- ':(exclude)dist/*'
git show <commit_hash> -- /PATH/TO/FILE
git submodule foreach --recursive 'git fetch --tags'
git submodule update --recursive
git shortlog -e -s -n
git log --author="Jon"
git commit --amend
Linux:
git rebase -p --onto SHA^ SHA
git push -f <REMOTE> <BRANCH_NAME>
Mac:
git rebase --onto SHA~ SHA
git push -f <REMOTE> <BRANCH_NAME>
Highlight multiple lines of code:
https://bitbucket.org/labelengine/createexpert/src/local/.env.development.yaml#lines-15,25
Highlight multiple sections of code:
https://bitbucket.org/labelengine/createexpert/src/local/.env.development.yaml#lines-15:25,30:32
ssh [email protected] 2fa_recovery_codes
{
"http-basic": {},
"github-oauth": {
"github.com": "__TOKEN__"}
}
Highlight code in Bitbucket:
https://bitbucket.org/labelengine/docker-tool/src/master/app/Proxy.php#lines-92