Skip to content

Instantly share code, notes, and snippets.

View alexbartsch's full-sized avatar

Alexander Bartsch alexbartsch

View GitHub Profile
@alexbartsch
alexbartsch / delete-branch.sh
Created December 7, 2016 15:35
Script for deleting local and remote branch
#!/bin/bash
git branch -d $1
git push origin :$1
git remote update origin --prune
@alexbartsch
alexbartsch / archive-branch.sh
Created December 7, 2016 15:36
Script for archiving git branch.
#!/bin/bash
git branch merged/$1 origin/$1
git push origin merged/$1
git push origin :$1
@alexbartsch
alexbartsch / update-branch-list.sh
Created December 8, 2016 08:49
Update remote branch list
#!/bin/bash
git remote update origin --prune
ssh <ssh-user>@<ssh-host> -L <local-port>:<remote-host>:<remote-port> -N
@alexbartsch
alexbartsch / docker-rmi-untagged.sh
Created April 3, 2017 12:40
Remove all untagged docker images
# Remove all untagged docker images
docker rmi $(docker images -q -f "dangling=true")
@alexbartsch
alexbartsch / scp-download-dir.sh
Created April 3, 2017 12:43
Download directory via scp
# Download directory via scp
scp -r <user>@<host>:/path/to/dir /path/to/target/destination
@alexbartsch
alexbartsch / docker-remove-all.sh
Last active April 26, 2017 11:12
Remove all docker images and containers
# Remove all docker images and containers
docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q) && docker rmi $(docker images -q)
docker build -t friendlyname . # Create image using this directory's Dockerfile
docker run -p 4000:80 friendlyname # Run "friendlyname" mapping port 4000 to 80
docker run -d -p 4000:80 friendlyname # Same thing, but in detached mode
docker ps # See a list of all running containers
docker stop <hash> # Gracefully stop the specified container
docker ps -a # See a list of all containers, even the ones not running
docker kill <hash> # Force shutdown of the specified container
@alexbartsch
alexbartsch / copy-to-remote.sh
Created April 5, 2017 19:26
Copy local files and directories to remote
# Copy local files and directories to remote
rsync -av /local/dir/ server:/remote/dir/
@alexbartsch
alexbartsch / delete-old-branches.sh
Last active September 6, 2018 08:45
Delete old local branches
git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}' | xargs git branch -d
# for german cli use
git branch -vv | grep 'origin/.*: entfernt]' | awk '{print $1}' | xargs git branch -d
helo client.mydomain.com
mail from:<[email protected]>
rcpt to:<[email protected]>
data
From: [email protected]
Subject: test mail from command line
this is test number 1
sent from linux box
.