Git Tips

Ignore Git Ignore and Full Reset

In case you need to reset HARD… remove folders files irrespective of .gitignore git clean -Xdf

Solution: Trigger a GitHub Actions Build

I ran into a Automation issue with GH-Pages, on PUSH it wasn’t triggering the environment, so, I added this stage Request GitHub Pages Build:

env:
GITHUB_TOKEN: ${{ secrets.DOCS_SITE_TOKEN }}
GITHUB_REPOSITORY: ${{ secrets.GITHUB_REPOSITORY }}
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
run: |
# As documented here, the GH-Pages behavior changed, 
# and the API must be ‘Triggered’
curl -L -X POST -H “Content-Type: application/json” \
      -H “Authorization: token ${GITHUB_TOKEN}” 
      “https://api.github.com/repos/${GITHUB_REPOSITORY}/pages/builds”

Solution: GIT_URL_1 and Jenkins Jobs – GIT_URL not working

In my jenkins job, I hit this issue where I was using GIT_URL to embed in my MANIFEST.MF. I found it was’t actually embedding the GIT Details in my Manifest.MF, I had to switch to GIT_URL_1 as described in Jenkins Git Plugin

Solution: Find all users who contributed since last tag

In my work, I need to report on the contributors since the last tag. A helpful shortcut is to use git with pretty formatting.

~$ git log --pretty=format:"%ae" 4.3.0.. | sort -u
a@users.noreply.github.com
b@users.noreply.github.com
c@us.ibm.com
d@us.ibm.com
e@bastide.org
f@us.ibm.com
g@ibm.com
h@us.ibm.com

Subm the Current Releases Download Count

Using the GitHub Release API, I counted the release downloads using the following pattern:

curl -u github-user-id:github-api-key \
   "https://api.github.com/repos/IBM/FHIR/releases?size=20" -o count.json
cat count.json | \
   jq -r '.[] | "\(.name),\(.assets[].name),\(.assets[].download_count)"'

The output is:

IBM FHIR Server 4.3.3,fhir-cli.zip,5
IBM FHIR Server 4.3.3,fhir-persistence-schema-4.3.3-cli.jar,5
IBM FHIR Server 4.3.3,fhir-server-distribution.zip,5

Git Submodules with Branch

Best to run this than edit .gitsubmodule

git submodule add -b main git@github.com:ibm/fhir submodules/v0.0.1/ibm-fhir-server