Skip to content

Instantly share code, notes, and snippets.

@punkrocker178
Last active September 18, 2021 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save punkrocker178/e09315d153ae572bf2eab9abdb2dceee to your computer and use it in GitHub Desktop.
Save punkrocker178/e09315d153ae572bf2eab9abdb2dceee to your computer and use it in GitHub Desktop.
Git commands
# Add remote
git remote add origin https://github.com/user/repo.git
# Save git credential
git config --global credential.helper store
# Enable this to separate git credentials for different repos
git config --global credential.github.com.useHttpPath true
# Delete branch local (multiple delete):
git branch -d $(git branch | grep -E ‘<branch-name>’)
# Delete branch remote:
git push -d origin <branch_name>
# Delete multiple branch using regex, grep is used for filter output with regex, sed then use that oupt to edit(omit “origin/”)
git push -d origin $(git branch -r | grep -E '<regex>' | sed -e 's/origin\///')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment