Bash argument set

Check if a bash argument is set in a script

File varcheck.sh

#!/usr/bin/env bash

if [[ ! -z ${1+x} ]]; then
    echo "var is set to '$1'";
else
    echo "var is unset";
fi

varcheck.sh will output: var is unset
Running varcheck.sh TADA will output: var is set to 'TADA'

Bash script get own path and name

pathfile.bash

#!/usr/bin/env bash

# Full path to file
echo "$(cd "$(dirname "$0")"; pwd)/$(basename "$0")"

# Full path of the directory the file is in with trailing slash
echo "$( cd "$(dirname "$0")" ; pwd -P )/"

# current directory name, not the path
echo "${PWD##*/}"

reapplying a reverted commit

So I made a booboo and already pushed a merge commit.
The merged branch had a few commits that where not ready for develop.
After reverting the merge one commit needed to be reapplied.
But a merge wont work, because it already is merged (and reverted).
What you can do is a cherry pick.

How I created the problem

git merge branch
git push origin develop

Here there was no way back, accept rebasing but that’s still out of my comfort zone (update dec-2019: still is).

How I solved it.

git revert eaf8c471 -m2
git cherry-pick fa9a6b0

Cherry pick just straight up applies the changes made in the files.
Where a merge applies the git changes.

Keep in mind this will only help if you need a handful of commits reapplied. Otherwise you will need to find an other way.
Or cherry pick a lot…