Git - sgml/signature GitHub Wiki
- Create one branch from another using
git fetch --verbose - Make code changes and commit
- Create a third branch from the original
- Patch a subset of the changes from the second branch
- Run tests
- Fix code
- Repeat running tests and fixing code
=====================================================================
MERGE CONFLICT BOUNDARIES β REWRITTEN AS POSITIVE ACTIONS (ANTONYMS)
=====================================================================
This diagram transforms every βavoidβ rule into a βdo thisβ rule by
reversing the meaning and advocating the antonymic behavior.
=====================================================================
BACKEND β MODEL LAYER
=====================================================================
[backend/models/*]
RISK: HIGH
DO THIS AT YOUR OWN RISK:
- Modify the same model file across multiple branches
- Replace existing content instead of appending
- Edit existing model files rather than creating new ones
- Centralize shared helpers inside model files
[frontend/src/store/modules/*]
RISK: HIGH
DO THIS AT YOUR OWN RISK:
- Modify the same Vuex module in multiple branches
- Replace mutation definitions instead of appending
- Rename state fields freely
- Consolidate logic into fewer modules
=====================================================================
BACKEND β REPOSITORIES
=====================================================================
[backend/repositories/*]
RISK: MEDIUM
DO THIS AT YOUR OWN RISK:
- Edit the same repository file across branches
- Replace query definitions
- Reorder functions
- Modify import paths directly
=====================================================================
BACKEND β SERVICES (MVC)
=====================================================================
[backend/services/views/*]
RISK: HIGH
DO THIS AT YOUR OWN RISK:
- Modify the same view file in multiple branches
- Replace response fields
- Centralize formatting helpers in shared files
=====================================================================
BACKEND β BLUEPRINTS (CONTROLLERS)
=====================================================================
[backend/services/api/*]
RISK: EXTREME
DO THIS AT YOUR OWN RISK:
- Add endpoints to the same Blueprint file
- Replace route definitions
- Reorder routes
- Modify shared router setup
=====================================================================
BACKEND β SUBSCRIPTIONS
=====================================================================
[backend/subscriptions/__init__.py]
RISK: EXTREME
DO THIS AT YOUR OWN RISK:
- Modify existing subscriber lines
- Reorder imports
- Replace subscriber registration blocks
- Edit existing subscription entries
[backend/subscriptions/publishers.py]
RISK: HIGH
DO THIS AT YOUR OWN RISK:
- Modify existing publisher functions
- Replace publisher definitions
- Reorder publisher functions
=====================================================================
BACKEND β DOMAIN EVENTS
=====================================================================
[backend/domain/*]
RISK: MEDIUM
DO THIS AT YOUR OWN RISK:
- Modify existing event constants
- Replace event names
- Reorder event definitions
=====================================================================
FRONTEND β VUEX STORE
=====================================================================
[frontend/src/store/modules/*]
RISK: HIGH
DO THIS AT YOUR OWN RISK:
- Modify the same Vuex module across branches
- Replace mutation definitions
- Rename state fields
- Consolidate multiple domains into one module
=====================================================================
FRONTEND β VIEWS (VUE COMPONENTS)
=====================================================================
[frontend/src/views/*]
RISK: VERY HIGH
DO THIS AT YOUR OWN RISK:
- Modify the same component across branches
- Replace template sections
- Edit parent components directly
=====================================================================
FRONTEND β ROUTER
=====================================================================
[frontend/src/router/routes.js]
[frontend/src/router/index.js]
RISK: EXTREME
DO THIS AT YOUR OWN RISK:
- Replace route definitions
- Reorder routes
- Modify existing guards
- Centralize all route groups into one file
=====================================================================
FRONTEND β PUBSUB (MUTATIONOBSERVER)
=====================================================================
[frontend/src/pubsub/subscribers.js]
RISK: EXTREME
DO THIS AT YOUR OWN RISK:
- Modify existing subscriber entries
- Reorder imports
- Replace subscription blocks
- Edit existing subscriber lines
=====================================================================
GLOBAL MERGE CONFLICT ACTIONS (ANTONYMS)
=====================================================================
1. Use a single file for multiple domains and layers
2. Replace route definitions instead of appending
3. Replace event constants instead of appending
4. Replace subscriber registration instead of appending
5. Reorder imports freely
6. Modify existing lines in shared files
7. Change function signatures frequently
8. Edit parent Vue components directly instead of using slots
9. Modify import paths directly instead of injecting dependencies
10. Increase coupling between layers by removing event boundaries
=====================================================================
END OF REWRITTEN ASCII DIAGRAM
=====================================================================
=====================================================================
MERGE CONFLICT BOUNDARIES β FULL LOSSLESS ASCII DIAGRAM
=====================================================================
This diagram isolates every mergeβconflict boundary from the full
Git workflow, grouped by layer and annotated with avoidance strategies.
Each boundary is shown as:
[LAYER / FILE AREA]
RISK LEVEL
WHY CONFLICTS OCCUR
HOW TO AVOID THEM
=====================================================================
BACKEND β MODEL LAYER
=====================================================================
[backend/models/*]
RISK: HIGH
WHY:
- Multiple branches often modify the same model file
- Shared fields, shared constructors, shared validation logic
AVOID:
- One model per branch
- Append-only changes
- Prefer new model files over editing existing ones
- Avoid shared helper functions inside model files
=====================================================================
BACKEND β REPOSITORIES
=====================================================================
[backend/repositories/*]
RISK: MEDIUM
WHY:
- Shared query functions
- Shared SQLAlchemy session usage
AVOID:
- One repository file per domain
- Append-only query definitions
- Never reorder functions
- Use dependency injection to avoid import edits
=====================================================================
BACKEND β SERVICES (MVVM) / PRESENTERS (MVP)
=====================================================================
[backend/services/services/*] (MVVM)
[backend/services/presenters/*] (MVP)
RISK: MEDIUM
WHY:
- Multiple branches add logic to the same service/presenter
- Shared helper functions
AVOID:
- One service/presenter per branch
- Never modify shared helpers
- Use pure functions with stable signatures
- Keep each domain in its own file
=====================================================================
BACKEND β VIEWMODELS (MVVM)
=====================================================================
[backend/services/viewmodels/*]
RISK: LOW
WHY:
- ViewModels are usually isolated per domain
- Rarely edited by multiple branches
AVOID:
- One VM per file
- No shared transformation helpers
- Append-only transformations
=====================================================================
BACKEND β VIEWS (JSON SERIALIZERS)
=====================================================================
[backend/services/views/*]
RISK: HIGH
WHY:
- Views often change when response shapes evolve
- Multiple branches may update the same serializer
AVOID:
- One view file per domain
- Append-only response fields
- Avoid shared formatting helpers
=====================================================================
BACKEND β BLUEPRINTS (CONTROLLERS)
=====================================================================
[backend/services/api/*]
RISK: VERY HIGH
WHY:
- Route definitions are centralized
- Multiple branches add endpoints to the same Blueprint
- Import ordering is fragile
AVOID:
- One Blueprint per domain
- Append-only route definitions
- Never reorder routes
- Never modify shared router setup
- Keep each endpoint in its own file if possible
=====================================================================
BACKEND β SUBSCRIPTIONS (EVENT SUBSCRIBERS)
=====================================================================
[backend/subscriptions/__init__.py]
RISK: EXTREME
WHY:
- ALL subscribers are registered in this single file
- Every branch must add imports + subscribe() calls
- Ordering changes cause conflicts
AVOID:
- Append-only subscriber registration
- Alphabetize imports to avoid reordering
- One subscriber registration block per branch
- Never modify existing subscriber lines
[backend/subscriptions/publishers.py]
RISK: HIGH
WHY:
- All publish_* functions live here
- Multiple branches add new publishers
AVOID:
- Append-only publisher definitions
- One publisher per branch
- Never reorder publisher functions
=====================================================================
BACKEND β DOMAIN EVENTS
=====================================================================
[backend/domain/*]
RISK: MEDIUM
WHY:
- Event constants shared across layers
- Multiple branches add new events
AVOID:
- One event file per domain
- Append-only event constants
- Never rename existing events
=====================================================================
FRONTEND β VUEX STORE
=====================================================================
[frontend/src/store/modules/*]
RISK: HIGH
WHY:
- Shared state, shared mutations
- Multiple branches modify same module
AVOID:
- One Vuex module per domain
- Append-only mutations
- Never rename state fields
- Prefer new modules over editing existing ones
=====================================================================
FRONTEND β VIEWMODELS (MVVM)
=====================================================================
[frontend/src/viewmodels/*]
RISK: LOW
WHY:
- Usually isolated per domain
AVOID:
- One VM per file
- Append-only computed fields
=====================================================================
FRONTEND β PRESENTERS (MVP)
=====================================================================
[frontend/src/presenters/*]
RISK: MEDIUM
WHY:
- Shared logic across components
AVOID:
- One presenter per file
- Avoid shared helpers
=====================================================================
FRONTEND β COMPONENTS (VUE)
=====================================================================
[frontend/src/components/*]
RISK: VERY HIGH
WHY:
- UI changes frequently
- Multiple branches modify same component
- Template changes cause lineβlevel conflicts
AVOID:
- One component per branch
- Use slots to avoid editing parent components
- Avoid shared layout components
=====================================================================
FRONTEND β ROUTER
=====================================================================
[frontend/src/router/routes.js]
[frontend/src/router/index.js]
RISK: EXTREME
WHY:
- Centralized route definitions
- Multiple branches add routes
- Reordering causes conflicts
AVOID:
- Append-only route definitions
- One file per route group
- Never reorder routes
- Never modify existing guards
=====================================================================
FRONTEND β PUBSUB (MUTATIONOBSERVER)
=====================================================================
[frontend/src/pubsub/subscribers.js]
RISK: EXTREME
WHY:
- All subscribers registered in one file
- Every branch adds new subscription lines
AVOID:
- Append-only subscription blocks
- Alphabetize imports
- Never modify existing subscriber entries
=====================================================================
GLOBAL MERGE CONFLICT AVOIDANCE RULES
=====================================================================
1. ONE FILE PER DOMAIN PER LAYER
2. APPEND-ONLY ROUTE DEFINITIONS
3. APPEND-ONLY EVENT CONSTANTS
4. APPEND-ONLY SUBSCRIBER REGISTRATION
5. NEVER REORDER IMPORTS
6. NEVER MODIFY EXISTING LINES IN SHARED FILES
7. USE PURE FUNCTIONS WITH STABLE SIGNATURES
8. USE SLOTS IN VUE TO AVOID PARENT EDITS
9. USE DEPENDENCY INJECTION TO AVOID IMPORT EDITS
10. USE EVENT-DRIVEN BOUNDARIES TO REDUCE COUPLING
=====================================================================
END OF MERGE CONFLICT BOUNDARY DIAGRAM
=====================================================================
- https://github.com/advisories
- https://github.blog/security/application-security/
- https://nvd.nist.gov/vuln/detail/CVE-2025-53818
- https://docs.github.com/en/search-github/github-code-search/understanding-github-code-search-syntax
- https://docs.github.com/en/organizations/keeping-your-organization-secure/managing-security-settings-for-your-organization/audit-log-events-for-your-organization
- https://vulnerablemcp.info/
- https://www.armorcode.com/blog/ai-code-blind-spots-and-how-we-solve-them
- https://www.oligo.security/blog/critical-rce-vulnerability-in-anthropic-mcp-inspector-cve-2025-49596
- https://news.ycombinator.com/item?id=44097390
- https://arxiv.org/html/2506.13538v4
- https://arxiv.org/pdf/2505.23634
https://github.com/git/git.github.io
https://gist.github.com/jedmao/5053440
-
https://circleci.com/docs/api/v2/index.html#operation/GetDecisionLog
-
https://discuss.circleci.com/t/rotating-all-of-the-organizations-deploy-keys/45949
https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows https://docs.docker.com/build/ci/github-actions/
https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
https://git-scm.com/docs/gitglossary
To see all branches, use fetch with the all and verbose options:
git fetch --all --verbose
To see all branches by name, use branch with the -r option, pipe to grep, and use sed to strip the word origin:
git branch -r | grep 'foo' | sed 's/origin\///'
To clone a specific branch, use `--single-branch --branch :
git clone --single-branch --branch foo [email protected]:foo-bar/baz.git
To sync a new repo, make a new folder and go to it:
mkdir foobarbaz cd foobarbaz
Create the directories, initialize the local git repo, and copy the code locally, create a branch:
mkdir framework
cd framework
git init
git clone ssh:foobarbaz.git
git remote remove origin
git remote add origin [email protected]:myname/foobar.git
git branch --set-upstream-to=origin/master master
git push --set-upstream origin master
To view remotes:
git remote -v show
To create a new branch, use git checkout -b:
git checkout -b myBranch
To link a new branch to a remote repo, use git branch --set-upstream-to:
git branch --set-upstream-to=origin/project/sprint-25-3-8to3-21 feature/INVPROD-2419
To list all remote branches, use git branch -r:
git branch -r
git branch -r | grep localhost
To switch branches, use git checkout with no options:
git checkout foo
To reset existing commits and create a new branch, stash your local env, create a branch from it, push the changes, switch to the current top-level branch, then pull in the latest changes:
git push
git stash
git stash branch local-changes
git add *
git push
git checkout master
git pull
git checkout -b newbranch
git checkout -p origin/local-changes
To check in, use the following process:
Add new files:
git add foo
Stash changed files:
git stash
Stash specific files:
git stash push [--] [<pathspec>...]
Pull new changes from the repo:
git pull
Show stashed file list:
git stash show
List stashed changes:
git stash list
Merge stashed changes:
git stash apply
Commit pushed changes:
git commit -m "foo bar baz"
Amend an unacceptable commit message:
git commit --amend
Undo an amended or other staged commit:
git reset 'HEAD@{1}' --soft
Revert the last pushed commit
git revert HEAD
Push new changes to the repo:
git push
Diff current remote to an older branch:
git diff FETCH_HEAD...feature/MAS-2782 --diff-filter=A
Diff last two revisions:
git diff 7194f404d5dccbb177bf4ea5aefa4d60081def31..452db42589004b3b2838933d6fcb6e046f980f28
One file copy from one commit to the local branch:
git show [commit hash] -- /foo/bar/baz.js > /foo/bar/baz.js
Remove a file
git rm -f ngtemplates.js
Reset the local branch HEAD to the remote branch HEAD
git reset
git checkout -b feature/INVPROD-4781
git branch --set-upstream-to=origin/feature/INVPROD-4781 feature/INVPROD-4781
git reset --hard FETCH_HEAD
-
Checkout master
-
Create a branch from it called misc/foo
-
Cherry pick from develop For example:
git push # sync the branch you're working on to its remote git pull # pull in the merged changes git fetch git checkout master # change branches to the one you want to modify git cherry-pick 533c2093200 #merge; Run git status, resolve conflicts, Run git add, then commit and push
If you pull all cherry pick files this way, you can create a yaml file and parse them using tac, awk, and xargs:
tac commits.yaml | awk '// {print $2}' | xargs git cherry-pick
-
Open a file
-
Find the line
-
Run
git blameon it. For example:git blame -L 374,376 schema.py
Find all Vue.js files in the pages path with the word 'organization':
repo:example.org/web.foo organization language:Vue path:pages
git log --since 2017-08-06 --remotes='*' --author=Foo* | grep commit
git log --pretty=format:"%h%x09%an%x09%ad%x09%s" --no-merges --since 2024-03-01 --author Foo | awk '!/Merge/'
git pull origin develop
git checkout -b myDevIntgrMerge #new branch
git checkout -p origin/foo -- ./test #pick branch and subdirectories
If you are several weeks or months behind on a branch, use the following process:
- For each conflict in each file, copy the HEAD changes and paste them to the end of the file
- For each conflict at the end of the file, compare the fragments to the source file in the branch
- Piece together the conflict hunks at the bottom of the file, then resolve the conflicts one by one
- Run a linter to make sure there are no syntax errors
- Merge the newly resolved files
When you get into a failed merge state, the index/stage splits into three. The first index is the abyss. The second index is your version of things. The third is the remote version of things. From here, you can either git checkout file --ours or git checkout file --theirs. This will accept either your file or their file into the stage, overriding the merge conflict in that file. git commit and that pesky merge conflict is dead.
git checkout origin/dev-intgr --ours -- foo.bar
git checkout origin/feature/baseline --ours -- ApplicationMockData.js
Auto reset and merge to rollback to an unmerged commit
git pull origin baseline
git reset HEAD 12345
git checkout -b rebaseline
git merge -s ours origin/feature/baseline
Rollback a repo to a merged commit
git checkout master
git checkout -b rollback
git checkout -p rev_to_rollback_to
Rollback a file to a merged commit
git checkout master
git checkout -b rollback
git checkout -p rev_to_rollback_to ./index.html
Apply this hunk to index and worktree [y,n,q,a,d,/,e,?]?
Using the following key:
y - apply this hunk to index and worktree n - do not apply this hunk to index and worktree q - quit; do not apply this hunk or any of the remaining ones a - apply this hunk and all later hunks in the file d - do not apply this hunk or any of the later hunks in the file g - select a hunk to go to / - search for a hunk matching the given regex j - leave this hunk undecided, see next undecided hunk J - leave this hunk undecided, see next hunk k - leave this hunk undecided, see previous undecided hunk K - leave this hunk undecided, see previous hunk s - split the current hunk into smaller hunks e - manually edit the current hunk ? - print help
Then push to the remote using:
git push --set-upstream origin myDevIntgrMerge #push merge
Merge to stable from unstable without accepting any commits
git merge origin/feature/INVPROD-2898-release -s ours
Merge to unstable from stable without auto resolving conflicts
git merge origin/integration -s recursive -X ours
Test for Bitbucket Conflicts Locally
You need to update your local master branch. So do the following steps :
git checkout master
git pull origin master
Resolve the conflicts here, then run:
git add *
git stash
git checkout << your branch >>
To pull in your local changes, run git stash apply
git merge master
Resolve the conflicts again
git add *
git commit
git push
For starters, git merge -s ours xyz is not the same as git merge -X ours xyz. The first uses merge strategy called βoursβ, and the second uses default βrecursiveβ merge strategy, but with βoursβ option. Creating two entities named βoursβ that do similar, but subtly different things is the epitome of bad interface design.
The β-sβ variant creates a commit that merges current branch and βxyzβ, but ignores all changes from xyz, so the resulting content would be identical to the current branch. This is useful for getting rid of unwanted branches when force-pushes and deletes are disabled. The β-Xβ variant only ignores changes from xyz that cause a conflict. Changes from xyz that do not cause a conflict will be included in the end result.
To fix an invalid commit message(no iTrack, no whitespace, etc), do the following:
git commit --amend
To clean mistaken deletes or checkins, do the following:
git reset --hard HEAD
Then clean the untracked files and directories with:
git clean -df
git reflog master@{one.week.ago}
git status --porcelain=2
-
Rename your local branch
git branch -m new-name
-
git branch -d example
-
Delete the old-name remote branch and push the new-name local branch.
git push origin :old-name new-name
-
Reset the upstream branch for the new-name local branch.
git push origin -u new-name
Create a netrc file:
Linux: vi ~/.netrc Windows: New-Item -Name _netrc -ItemType File -Path $env:userprofile Set the permissions for your eyes only:
chmod 0600 ~/.netrc Then add the bitbucket URL and your username and password:
machine bitbucket.etrade.com login myusername password mypassword
https://www.codementor.io/@maksimivanov/add-specific-lines-with-git-patch-eais7k69j
https://thoughtbot.com/blog/intent-to-add
https://dev.to/krnsk0/a-thorough-introduction-to-git-s-interactive-patch-mode-4bl6
https://git-scm.com/docs/git-apply
- bugfix/: bug fixes
- hotfix/: hot fixes for production
- release/: code for new feature releases
- chore/: documentation, copy, and image
- experiment/: demos
- wip/: drafts
- improvement/: refactoring
import subprocess
import sys
def fetch_comments_by_user(user):
try:
# Run the git log command to get commit messages by the specific user
result = subprocess.run(
["git", "log", "--author={}".format(user), "--pretty=format:%H - %s"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
if result.returncode != 0:
print("Error:", result.stderr)
return
# Print the commit messages
commits = result.stdout.split("\n")
for commit in commits:
print(commit)
except Exception as e:
print("An error occurred:", e)
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python fetch_comments.py <user>")
else:
user = sys.argv[1]
fetch_comments_by_user(user)
https://www.theregister.co.uk/2005/04/14/torvalds_attacks_tridgell/
https://www.aosabook.org/en/git.html
https://spderosso.github.io/onward13.pdf
https://news.slashdot.org/story/16/05/10/1840255/11-years-after-git-bitkeeper-is-open-sourced
http://wiki.c2.com/?MercurialVersionControl
https://www.rath.org/why-you-should-give-mercurial-a-shot.html
https://www.tshooter.com.br/en/2016/03/07/eight-reasons-to-prefer-git-to-invs-tfvc/
https://lwn.net/Articles/574079/
https://tech.blog.aknin.name/2010/05/14/switching-to-mercurial-taming-zsh/
https://wilsonmar.github.io/tfs-vs-github/
https://blogs.microsoft.co.il/leonj/2017/06/05/avoid-excessive-database-growth-for-git-tfs-users/
https://thenewstack.io/microsoft-forged-scalable-git/
http://help.manuscript.com/7984/mercurial-branches-versus-kiln-branches
https://graphite.dev/guides/git-branch-naming-conventions
https://wiki.gentoo.org/wiki/Git
http://www.linuxfromscratch.org/blfs/view/svn/general/git.html
https://www.freshports.org/devel/git/
https://github.com/git/git/blob/master/Documentation/git-grep.txt
https://www.endpoint.com/blog/2010/04/26/make-git-grep-recurse-into-submodules
https://github.com/foo/bar/compare/master...develop
name: Count ALLCAPS Words
on:
push:
pull_request:
jobs:
allcaps-scan:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install Pylint
run: pip install pylint
- name: Run Pylint with custom ALLCAPS checker
id: pylint_run
run: |
pylint_output=$(pylint --output-format=text . || true)
echo "$pylint_output" > pylint_output.txt
count=$(grep -c "allcaps-word" pylint_output.txt || true)
echo "count=$count" >> $GITHUB_OUTPUT
- name: Display ALLCAPS count
run: echo "Found ${{ steps.pylint_run.outputs.count }} ALLCAPS words"
name: Matrix Example
on:
schedule:
- cron: "0 * * * *" # runs once per hour
jobs:
staggered-task:
runs-on: ubuntu-latest
strategy: # https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#defining-a-matrix
matrix: # https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
delay: [0, 600, 1200, 1800, 2400, 3000] # seconds (0, 10, 20, 30, 40, 50 minutes)
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Wait before running
run: sleep ${{ matrix.delay }}
- name: Run task
run: ./task.sh
name: Matrix Example
on:
schedule: # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
- cron: "0 * * * *" # runs once per hour (cron syntax: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule)
jobs:
staggered-task:
runs-on: ubuntu-latest
strategy: # https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#defining-a-matrix
matrix: # https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
delay: [0, 600, 1200, 1800, 2400, 3000] # seconds (0, 10, 20, 30, 40, 50 minutes)
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Wait before running
run: sleep ${{ matrix.delay }}
- name: Run task
run: ./task.sh
- https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-variables
- https://docs.github.com/en/actions/reference/workflows-and-actions/contexts
- https://stackoverflow.com/questions/79633383/issue-with-path-in-github-actions-using-python
- https://stackoverflow.com/questions/70415156/github-action-ubuntu-add-to-pythonpath
- https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
https://www.ianwootten.co.uk/2020/10/23/publishing-to-pypi-using-github-actions/
- https://docs.github.com/en/actions/how-tos/secure-your-work/security-harden-deployments/oidc-in-aws
- https://aws.amazon.com/blogs/security/use-iam-roles-to-connect-github-actions-to-actions-in-aws/
- https://www.youtube.com/watch?v=Io5UFJlEJKc
-
ghcc
-
dotcom_user"
-
Reference: https://github.com/privacy/cookies
GITHUB_WORKFLOWGITHUB_RUN_IDGITHUB_RUN_NUMBERGITHUB_ACTIONGITHUB_ACTIONS
GITHUB_REPOSITORYGITHUB_REPOSITORY_OWNERGITHUB_REFGITHUB_REF_NAMEGITHUB_REF_TYPEGITHUB_SHA
GITHUB_WORKSPACERUNNER_OSRUNNER_ARCHRUNNER_TEMPRUNNER_TOOL_CACHE
GITHUB_EVENT_NAMEGITHUB_EVENT_PATH
- Secrets added in the repository settings, e.g.,
MY_SECRET
name: Run Script Daily
on:
schedule:
- cron: '0 0 * * *' # This cron expression schedules the job to run once a day at midnight UTC
workflow_dispatch: # Allows you to manually trigger the workflow
jobs:
run-script:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Run specified file
run: python ${{ secrets.SCRIPT_FILE }}
env:
SCRIPT_FILE: ${{ secrets.SCRIPT_FILE }}
https://briangrinstead.com/blog/publishing-vite-project-to-github-pages/
This table shows which Airflow features can be replaced with simpler tools like GitHub Actions or EC2 cron jobs. It uses plain language and includes notes on CPU and memory usage.
| Airflow Feature | GitHub Actions Version | EC2 Cron Job Version | What It Means | CPU Requirements | Memory Requirements |
|---|---|---|---|---|---|
| Scheduled Tasks |
on: schedule with cron |
crontab entries |
Run tasks at specific times | Very low β just a trigger | Very low |
| One-Step Jobs | Single job step | Shell or Python script | Do one thing, like delete files or call API | Low to medium β depends on task | Low to medium β depends on task |
| Set Up Environment |
runs-on: + setup actions |
EC2 bootstrap or AMI | Prepare the machine before running jobs | Medium β container or VM startup | Medium β container or VM setup |
| Basic Logging | GitHub logs | Redirect output to log files | Save what happened during the job | Very low | Low |
| Alerts (Success/Fail) | Slack/email on failure |
mail or webhook on exit |
Notify someone if job worked or failed | Very low | Very low |
| Retry if Fails |
continue-on-error + retries |
Retry loop in script | Try again if something goes wrong | Low to medium β retry adds load | Low to medium |
| Use Variables | Inputs or env vars | Script args or env vars | Change settings without editing the script | Negligible | Negligible |
| Keep Secrets Safe | GitHub Secrets | AWS Secrets Manager or .env
|
Hide passwords or keys | Very low | Low |
Some Airflow features are harder to replicate with simple tools:
- Task dependencies and branching
- Waiting for events (like a file arriving)
- Monitoring lots of jobs at once
- Visual dashboards and retry control
https://git-scm.com/docs/git-stash
https://www.linux.org/docs/man7/gitrevisions.html
http://people.irisa.fr/Anthony.Baire/git/git-advanced-handout.pdf
https://github.com/git/git/blob/master/Documentation/git-checkout.txt
https://www.kernel.org/pub/software/scm/git/docs/git-checkout.html
https://stackoverflow.com/questions/22297284/create-a-git-diff-of-a-file-from-sourcetree
https://devtut.github.io/git/cherry-picking.html#copying-a-commit-from-one-branch-to-another
https://www.python.org/dev/peps/pep-0103/
https://docs.moodle.org/dev/Git_for_developers
http://www.noah.org/wiki/Git_notes
https://www.wikihow.com/Use-Git-Effectively
https://www.sbf5.com/~cduan/technical/git/git-3.shtml
https://kofoedanders.com/git-cooperation-simplified/
http://joemaller.com/990/a-web-focused-git-workflow/
https://news.ycombinator.com/item?id=12785200
http://travisjeffery.com/b/2012/02/search-a-git-repo-like-a-ninja/
https://help.github.com/articles/changing-a-commit-message/
http://git-extensions-documentation.readthedocs.io/en/latest/modify_history.html
https://davidwalsh.name/git-default-remote
https://www.cloudbees.com/blog/advanced-git-jenkins
https://community.atlassian.com/t5/Bitbucket-questions/behind-ahead-incorrect/qaq-p/4749
https://confluence.atlassian.com/bitbucketserver050/automatic-branch-merging-913474751.html
https://git-scm.com/book/en/v2/Git-Internals-Transfer-Protocols
https://blog.petrzemek.net/2016/07/10/git-patch-mode-all-the-way/
http://mindspill.net/computing/linux-notes/git-diff-tree-whitespace/
https://blog.bigballofwax.co.nz/2011/12/15/fixing-whitespace-when-apply-patches-with-git/
http://jyx.github.io/blog/2012/03/09/apply-patches-in-git/
https://robots.thoughtbot.com/send-a-patch-to-someone-using-git-format-patch
http://gitster.livejournal.com/28309.html
https://davidwalsh.name/git-export-patch
http://nithinbekal.com/posts/git-patch/
http://git-extensions-documentation.readthedocs.io/en/latest/patches.html
https://kennyballou.com/blog/2015/10/art-manually-edit-hunks/
https://www.kernel.org/pub/software/scm/git/docs/git-apply.html
http://www.olitreadwell.com/2014/12/27/git-commit-interactivity/
https://git-scm.com/docs/diff-generate-patch
https://www.kernel.org/pub/software/scm/git/docs/git-rerere.html
http://legacy.python.org/dev/peps/pep-0103/
http://genomewiki.ucsc.edu/index.php/Resolving_merge_conflicts_in_Git
https://git-scm.com/docs/merge-strategies
http://www.drdobbs.com/tools/three-way-merging-a-look-under-the-hood/240164902
http://blog.ezyang.com/2010/01/advanced-git-merge/
https://ariya.io/2013/09/fast-forward-git-merge
https://git-scm.com/docs/git-merge-file
http://blog.ezyang.com/2011/07/synthetic-git-merges/
http://www-cs-students.stanford.edu/~blynn/gitmagic/ch07.html
https://stackoverflow.com/questions/26157114/some-choices-in-interactive-mode-dont-work-on-git
https://wiki.freebsd.org/GitConversion
https://www.devroom.io/2010/06/10/cherry-picking-specific-commits-from-another-branch/
https://ninc.centreforbrainhealth.ca/sites/default/files/pictures/git.pdf
http://www.gelato.unsw.edu.au/archives/git/0512/13748.html
https://www.slideshare.net/wjmuse/git-35996727
https://www.slideshare.net/JosManuelVegaMonroy/git-session20122013-18929189
http://gitpython.readthedocs.io/en/stable/reference.html
https://dyerlab.ces.vcu.edu/2016/06/22/google-drive-git/
https://en.wikibooks.org/wiki/Git/Internal_structure
https://git-scm.com/book/en/v1/Git-and-Other-Systems-Git-and-Subversion
https://blog.ostermiller.org/git-remove-from-history
https://en.wikibooks.org/wiki/Commit_Often,_Perfect_Later,_Publish_Once:_Git_Best_Practices
https://sethrobertson.github.io/GitBestPractices/
http://blog.kablamo.org/2013/12/08/git-restore/
https://stackoverflow.com/questions/6531241/how-to-use-expect-and-git-clone?rq=1
https://www.atlassian.com/blog/git/extending-git
https://easyengine.io/tutorials/git/git-resolve-merge-conflicts/
https://git.wiki.kernel.org/index.php/Aliases
http://www.cirosantilli.com/git-tutorial/
https://git-scm.com/docs/revisions
https://github.com/bricoleurs/bricolage/wiki/Merging-with-Git
http://gitolite.com/detached-head.html
http://www.it3.be/2014/05/07/git-head-detached/
https://www.alexmoreno.net/head-detached-originmaster
https://git-scm.com/docs/git-checkout#_detached_head
https://stackoverflow.com/questions/36727469/bitbucket-crlf-issue
https://mirrors.edge.kernel.org/pub/software/scm/git/docs/technical/api-index.html
https://help.github.com/articles/error-permission-denied-publickey/
https://coderwall.com/p/ovjobq/git-merge-strategy-if-you-have-a-conflict
https://ikriv.com/blog/?p=2419
https://verboselogging.com/2010/06/25/copy-merge-with-git
https://blog.tankywoo.com/2014/05/20/git-merge-strategy-ours-and-theirs.html
https://www.reddit.com/r/programming/comments/kt058/gits_merge_recursive_strategy_explained/
https://git.seveas.net/the-meaning-of-refs-and-refspecs.html
https://medium.com/@Sergeon/using-javascript-in-your-git-hooks-f0ce09477334
https://aboullaite.me/deep-dive-into-git-git-refs/
http://gitolite.com/tips-3.html
https://help.github.com/articles/ignoring-files/
http://www.codeblocq.com/2016/01/Untrack-files-already-added-to-git-repository-based-on-gitignore/
https://www.atlassian.com/git/tutorials/saving-changes/gitignore
https://stackoverflow.com/questions/7751555/how-to-resolve-git-stash-conflict-without-commit
https://git-scm.com/book/en/v1/Git-Tools-Stashing
https://www.oliverdavies.uk/blog/git-format-patch/
https://git.kernel.org/pub/scm/git/git.git/plain/Documentation/SubmittingPatches?id=master
https://makandracards.com/makandra/2521-git-how-to-create-and-apply-patches
https://www.tutorialspoint.com/git/git_patch_operation.htm
https://www.lullabot.com/articles/git-best-practices-upgrading-the-patch-process
https://www.usna.edu/Users/cs/aviv/classes/si485h/s17/submit.html
https://cbx33.github.io/gitt/chap8-6.html
https://jaytaylor.com/notes/node/1475947476000.html
https://www.drupal.org/node/1129120
https://help.github.com/articles/ignoring-files/
https://git-scm.com/docs/gitignore
https://www.atlassian.com/git/tutorials/using-branches/merge-strategy
https://www.oreilly.com/library/view/git-pocket-guide/9781449327507/ch11.html
https://kernelnewbies.org/FirstKernelPatch
https://hugogiraudel.com/2014/03/17/git-tips-and-tricks-part-2/
https://git-scm.com/docs/git-config
http://web.mit.edu/jhawk/mnt/spo/git/www/git-config.html
https://git-scm.com/docs/gitattributes
https://unspecified.wordpress.com/2010/03/26/why-git-aint-better-than-x/
https://dev.to/ben/is-git-the-be-all-and-end-all-of-version-control-4lp
https://news.ycombinator.com/item?id=12621955
https://news.ycombinator.com/item?id=12622746
https://code.fb.com/core-data/scaling-mercurial-at-facebook/
https://www.reddit.com/r/PHP/comments/9m6csh/what_is_the_absolute_worst_and_still_around_today/
https://www.reddit.com/r/programming/comments/71btyi/perforce_vs_svn_vs_git_vs_hg_for_gamedev/
https://devblogs.microsoft.com/devops/supercharging-the-git-commit-graph-ii-file-format/
https://backlog.com/git-tutorial/rewriting-history/change-commit-using-rebase/
https://juderosario.com/2016/09/25/gitting-the-commit-message-right/
https://help.github.com/en/articles/changing-a-commit-message
https://tickets.suresupport.com/faq/article-1905/en/using_git_to_push_changes_to_your_live_website
http://nicolasgallagher.com/git-checkout-specific-files-from-another-branch/
- https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints
- https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints
- /settings/personal-access-tokens
- /settings/apps
- /settings/installations
git submodule add [email protected]:myorg/myrepo.myreporepo.git
import sys
sys.path.append("pathToProjectB")
Update the pip/poetry install to install the dependencies of the submodule
- https://stackoverflow.com/questions/70970350/setting-path-for-git-submodule-within-a-python-project
- https://dev.to/dwd/git-submodules-revisited-1p54
- https://news.ycombinator.com/item?id=17058230
- https://chrisjean.com/git-submodules-adding-using-removing-and-updating/
- https://www.atlassian.com/git/tutorials/git-submodule?ysclid=mcgzshyo9g276419393
- https://git.github.io/htmldocs/gitsubmodules.html
- https://github.com/spotlesscoder/chris-sanders.github.io/blob/master/_posts/2019-02-07-charm-template-pytest.md?plain=1
- https://github.com/unskript/Awesome-CloudOps-Automation/blob/master/README_extending_docker.md?plain=1
- https://www.alexhyett.com/git-flow-github-flow/
- https://www.flagship.io/git-branching-strategies/
- https://cm-gitlab.stanford.edu/help/workflow/gitlab_flow.md
| Process | Workflow | Strengths | Weaknesses | Typical Use Cases |
|---|---|---|---|---|
| Direct push to master without review | Developer commits directly to master branch, no peer review. |
Fast, minimal overhead, immediate deployment. | High risk of bugs, no peer validation, breaks CI/CD discipline, poor audit trail. | Solo projects, prototypes, experimental repos. |
| Push to non-master with review, then push to master with review | Developer pushes to feature branch β code review β merge to master (reviewed again). | Strong quality control, double review ensures correctness, clear history. | Slower, more overhead, potential bottlenecks, requires disciplined reviewers. | Critical systems, regulated industries, high-stakes production code. |
| Push to non-master without review, then push to master with review | Developer pushes to feature branch (no review) β later merge to master with review. | Balance of speed and safety, review happens before production merge, feature branches allow isolation. | Early mistakes may linger until final review, less feedback during development, risk of large PRs. | Mid-size teams, moderate-risk projects, when speed matters but master must stay clean. |
GitHub uses a 404 Not Found response instead of a 403 Forbidden response to avoid confirming the existence of private repositories.
- https://docs.github.com/en/rest/using-the-rest-api/troubleshooting-the-rest-api?apiVersion=2022-11-28
- https://gist.github.com/victorbordo/5581fdfb89ed93bf3eb2b478529b9e38
- https://docs.github.com/en/search-github/searching-on-github/searching-for-repositories
#!/usr/bin/env python3
"""
get_review_comments_by_author_on_merged_prs.py
Usage:
GITHUB_TOKEN=xxx python get_review_comments_by_author_on_merged_prs.py owner repo comment_author
What it does:
- Lists closed pull requests for owner/repo (paginated)
- Keeps only merged PRs
- For each merged PR, fetches review comments and returns only those authored by comment_author
- Prints a JSON array of matched PRs with matched comments
Requirements:
- Python 3.7+
- requests
"""
import os
import sys
import json
import time
import requests
from typing import List, Dict, Any, Optional
API_BASE = "https://api.github.com"
PER_PAGE = 100
SLEEP_ON_RATE = 1.0 # backoff between requests to be polite; increase if you hit rate limits
def get_auth_headers(token: str) -> Dict[str, str]:
return {"Authorization": f"token {token}", "Accept": "application/vnd.github.v3+json", "User-Agent": "gh-review-comments-by-author-script/1.0"}
def paginate(url: str, params: Optional[Dict[str, Any]], headers: Dict[str, str]) -> List[Dict[str, Any]]:
items: List[Dict[str, Any]] = []
while url:
resp = requests.get(url, params=params, headers=headers)
if resp.status_code != 200:
raise SystemExit(f"HTTP {resp.status_code} fetching {url}: {resp.text}")
page_data = resp.json()
if isinstance(page_data, list):
items.extend(page_data)
else:
# sometimes endpoints return an object wrapper
items.append(page_data)
# parse Link header for next
link = resp.headers.get("Link", "")
next_url = None
if link:
parts = link.split(",")
for part in parts:
if 'rel="next"' in part:
# format: <https://api.github.com/...>; rel="next"
start = part.find("<") + 1
end = part.find(">", start)
next_url = part[start:end]
break
url = next_url
params = None # subsequent pages: params already in next_url
time.sleep(SLEEP_ON_RATE)
return items
def list_closed_prs(owner: str, repo: str, headers: Dict[str, str]) -> List[Dict[str, Any]]:
url = f"{API_BASE}/repos/{owner}/{repo}/pulls"
params = {"state": "closed", "per_page": PER_PAGE}
return paginate(url, params, headers)
def get_pr(owner: str, repo: str, number: int, headers: Dict[str, str]) -> Dict[str, Any]:
url = f"{API_BASE}/repos/{owner}/{repo}/pulls/{number}"
resp = requests.get(url, headers=headers)
if resp.status_code != 200:
raise SystemExit(f"HTTP {resp.status_code} fetching PR {number}: {resp.text}")
return resp.json()
def list_review_comments(owner: str, repo: str, pull_number: int, headers: Dict[str, str]) -> List[Dict[str, Any]]:
url = f"{API_BASE}/repos/{owner}/{repo}/pulls/{pull_number}/comments"
params = {"per_page": PER_PAGE}
return paginate(url, params, headers)
def main():
if len(sys.argv) < 4:
print("Usage: GITHUB_TOKEN=xxx python get_review_comments_by_author_on_merged_prs.py owner repo comment_author")
sys.exit(1)
owner, repo, comment_author = sys.argv[1], sys.argv[2], sys.argv[3]
token = os.environ.get("GITHUB_TOKEN")
if not token:
print("Set GITHUB_TOKEN environment variable with repo access")
sys.exit(1)
headers = get_auth_headers(token)
print(f"Listing closed PRs for {owner}/{repo}...")
closed_prs = list_closed_prs(owner, repo, headers)
print(f"Found {len(closed_prs)} closed PR(s). Scanning for merged PRs...")
results: List[Dict[str, Any]] = []
for pr_summary in closed_prs:
# PR summary may include merged_at, but to be safe fetch full PR to ensure correct merged_at and metadata
if not pr_summary.get("merged_at"):
continue # skip unmerged
pr_number = pr_summary.get("number")
if pr_number is None:
continue
pr = get_pr(owner, repo, pr_number, headers)
if not pr.get("merged_at"):
continue
# fetch review comments for this PR
review_comments = list_review_comments(owner, repo, pr_number, headers)
# filter by comment author login
authored = [c for c in review_comments if c.get("user") and c["user"].get("login") == comment_author]
if not authored:
continue
# shape output (trim heavy fields if you want)
results.append({
"pr_number": pr_number,
"pr_title": pr.get("title"),
"pr_url": pr.get("html_url"),
"merged_at": pr.get("merged_at"),
"matched_count": len(authored),
"comments": [
{
"id": c.get("id"),
"body": c.get("body"),
"path": c.get("path"),
"position": c.get("position"),
"commit_id": c.get("commit_id"),
"created_at": c.get("created_at"),
"updated_at": c.get("updated_at"),
"url": c.get("html_url"),
} for c in authored
]
})
print(f"Matched PR #{pr_number} β {len(authored)} comment(s) by {comment_author}")
print(f"\nDone. Found {len(results)} merged PR(s) with review comments by {comment_author}.\n")
print(json.dumps(results, indent=2))
if __name__ == "__main__":
main()