Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # undo remote push
- git reset <commit_hash>
- git push -f <remote_name> <branch_name>
- # undo remote push preserve changes
- git reset <commit_hash>
- git stash
- git push -f <remote_name> <branch_name>
- git stash pop
- # alias for restoring files on git ( git restore-file my-file )
- git config alias.restore-file '!git checkout $(git rev-list -n 1 HEAD -- "$1")^ -- "$1"'
- # keep changes only in local repo, do not include file changes on commit
- git update-index --assume-unchanged <file>
- # undo update-index
- git update-index --no-assume-unchanged <file>
- # undo commit, delete changes
- git reset --hard HEAD~1
- # undo commit, keep changes
- git reset HEAD~1
- # undo commit, keep changes and indices
- git reset --soft HEAD~1
- # delete all local branches starting with 'feature/'
- git branch | grep 'feature/' | xargs git branch -d
- # rename local branch if not in branch
- git branch -m <oldname> <newname>
- # rename local branch if in branch
- git branch -m <newname>
- # push current branch to remote
- git push origin HEAD
- # remove all .swp files
- git ls-files | grep '\.swp$' | xargs git rm
- # write and quit vim, press Esc then
- :wq // then press Enter
- # stash changes
- git stash save --keep-index
- # undo push
- git push -f origin last_known_good_commit:branch_name
- # alias multiple commands in .git/config
- [alias]
- kuzza = !git checkout develop && git fetch origin develop && git merge
- # fetch and merge remote
- git fetch <remote> <branch>
- git merge <remote>/<branch>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement