Last active
March 9, 2023 09:25
-
-
Save thomascrepain/7705378 to your computer and use it in GitHub Desktop.
Git Cheat sheet - much used but not remembered
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# refresh remote branches | |
git fetch -p | |
# checkout remote branch | |
git checkout -t origin/branchname | |
# delete local branch | |
git branch -d branchname | |
# list remote branch | |
git branch -r | |
# delete remote branch | |
git push origin:branchname | |
# create tag | |
git tag tagname | |
# remove tag | |
git tag -d tagname | |
# merge 1 commit from other branch into current branch | |
git cherry-pick commithash | |
# push tags to remote origin | |
git push --tags origin | |
# undo git add before commit | |
git reset filename | |
# changelogs between versions | |
# Pretty format, see: https://git-scm.com/docs/pretty-formats | |
git log --no-merges --pretty=format:'%h : %s' 1.3..1.4 | |
# 'git rm' all deleted files shown by 'git status' | |
git rm `git status | grep deleted | awk '{print $3}'` | |
# Add the devbox as a remote | |
git remote add devbox [email protected]:/var/www/websitename | |
# fetch upstream and force it in origin/master - use for Pimcore repo | |
git fetch upstream | |
git checkout master | |
git reset --hard upstream/master | |
git push origin master --force | |
# Config | |
## Remove a/ & b/ prefix on paths in git diff | |
git config --global diff.noprefix true | |
## Use vim as default editor | |
git config --global core.editor "vim" | |
## pull should rebase and preserve merges | |
git config --global pull.rebase merges |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment