Skip to content

Instantly share code, notes, and snippets.

@Sushant
Last active December 4, 2022 06:18
Show Gist options
  • Save Sushant/3174585 to your computer and use it in GitHub Desktop.
Save Sushant/3174585 to your computer and use it in GitHub Desktop.
Git uncommon but useful commands
# Delete Remote branch:
$ git push origin :newfeature
# Show details of a specific commit:
$ git show 44f1f96e23ecb835e4442bf464861231b2d96d7e
# Merge specific files from another branch:
# You are in the branch you want to merge to
$ git checkout <branch_you_want_to_merge_from> <file_paths...>
# Git export
$ git archive HEAD | gzip > archive.tar.gz
# Git diff against a stash
$ git stash show -p stash@{0}
# Apply a stash
$ git stash apply stash@{1}
# Remove branches that have been deleted on remote repo
$ git remote prune origin
# Remove branches that have been merged with master
$ git branch --merged master | grep -v "\* master" | xargs -n 1 git branch -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment