-
$ git push -d origin <branch_name>
$ git branch -d <branch_name>
-
$ git remote prune origin
-
- Check out 'master'
$ git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
-
-
$ git update-index --assume-unchanged "main/dontcheckmein.txt"
and to undo that:
$ git update-index --no-assume-unchanged "main/dontcheckmein.txt"
-
-
by commit message:
$ git log -g --grep=search_for_this
-
by commit changes:
$ git log -g -Ssearch_for_this
-
this also works but may be slower, it only shows text-added results
$ git grep search_for_this $(git log -g --pretty=format:%h)
-
-
$ git fetch origin master:master
-
$ git config credential.helper store
$ git pull
- See current user:
$ git config user.name
$ git config user.email
- Update current user globally
$ git config --global user.name "Aliaksei Yankou"
$ git config --global user.email "yankouav@gmail.com"
- Will pick all commits between A (older, including A) and B (later, including B)
$ git cherry-pick A^..B
- Commit all your changes
- Remove everything from the repository
$ git rm -r --cached .
- Re add everything
$ git add .
- Commit
$ git commit -m ".gitignore fix"
To format messages like [branchName] commit message Update
.git/hooks/prepare-commit-msg
with the following - See current user:
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_EXCLUDED=$(printf "%s\n" "${BRANCHES_TO_SKIP[@]}" | grep -c "^$BRANCH_NAME$")
BRANCH_IN_COMMIT=$(grep -c "\[$BRANCH_NAME\]" $1)
if [ -n "$BRANCH_NAME" ] && ! [[ $BRANCH_EXCLUDED -eq 1 ]] && ! [[ $BRANCH_IN_COMMIT -ge 1 ]]; then
sed -i.bak -e "1s%^%[$BRANCH_NAME] %" $1
fi
$ git diff --shortstat <branch_name>
git config --global alias.lgb "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%n' --abbrev-commit --date=relative --branches"
git lgb