Brief tips and tricks from various places.
This example uses the main
branch. Replace main
with desired branch.
git fetch origin
git reset --hard origin/main
git clean -f
To see which files will be removed by clean
without removing them, run:
git clean -n -f
After completing work on a branch, you can merge back to the main
branch and remove it from both the local and remote. This example uses the working branch named working_branch
.
git checkout main
git pull origin main
git merge working_branch
# Fix any merge conflicts, as necessary.
git push -u origin main
git branch -d working_branch # Delete local branch
git push origin --delete working_branch # Delete remote branch
git fetch --all --prune # Remove references to remote branch
Git tags are useful for maintaining check points of milestones in the development process. Typically, semantic versioning is recommended for tag numbers. To apply tags:
git checkout main # Ensure that you are on main branch.
git tag -a vX.Y.Z -m "Annotation for this tag." # Semantic verison tag for version X.Y.Z to local (on current branch).
git push --tags # Apply tag to remote.
git ls-remote --tags # Display tags on remote.
The Git log
command is one of the hidden gems of Git. To see all of the commits in the last X hours with the earliest first, run:
git log --since="72 hours ago" --until="now" --reverse --pretty=format:"%h" | head -1
The ST2 API is useful for prototyping and getting more detailed output than is possible when using the standard ST2 command-line tools. However, using the API requires an authentication token (or API key). You can create a simple shell script to auto-generate the token using your logged in ST2 account and set it to the ST2_AUTH_TOKEN
environment variable.
ST2_AUTH_TOKEN=$(curl -X POST -k -u yourusername:'yourpassword' https://myhost.example.com/auth/v1/tokens | jq -r '."token"')
Now, to run an API command at the command line using this API token, just include the ST2_AUTH_TOKEN
environment variable in the headers.
curl -H "X-Auth-Token: $ST2_AUTH_TOKEN" -k https://myhost.example.com/api/v1/actions
To read (and, optionally, decrypt) values from the keystore using Jinja (versus YAQL) syntax in ST2, you can use a variety of possible syntax options:
{{ st2kv(PASSWORD_KEYS.keyname, decrypt=true) }}
api_user: "{{ st2kv.system.CUST___phillips66 |from_json_string |jsonpath_query('FORTIMANAGER.apiuser')|first }}"
api_pass: "{{ st2kv.system.phillips66___fmg_apipass| decrypt }}"