Tracking updates to Awesome repositories
Track Awesome List Updates Daily: Provides RSS feed of commits to many of the awesome repositories.
Here are a bunch of git related commands and scripts I never remember.
Restore file from upstream
git restore -s origin/master content/_index.mdPrint out only filenames of changes files
# For working files
git diff --name-only
# For staged files
git diff --cached --name-only
# Or
git status -sClient-side commit, push, post-push command
After a push, I usually have some command I want to run. So this is a zsh function that takes in a commit command and the name of an executable and its arguments and runs them. If the push fails, it exists out before running the additional commands.
function lazygit() {
# Initialize variables
local commit_message=""
local post_push_command=""
local post_push_args=""
# Parse parameters
for arg in "$@"; do
if [[ $arg == --* ]]; then
post_push_command="${arg#--}"
elif [[ -n "$post_push_command" ]]; then
post_push_args="$post_push_args $arg"
else
commit_message="$arg"
fi
done
# Ensure a commit message is provided
if [ -z "$commit_message" ]; then
echo "Error: Commit message is required."
return 1
fi
# Check if the current directory is a valid Git work tree
if ! git rev-parse --is-inside-work-tree &> /dev/null; then
echo "Error: This operation must be run in a Git work tree."
return 1
fi
# Check if the post-push command exists
if [ -n "$post_push_command" ]; then
if ! command -v "${post_push_command%% *}" &> /dev/null; then
echo "Error: Command '${post_push_command%% *}' not found. Files were not committed or pushed."
return 1
fi
fi
# Perform git operations
git add .
if ! git commit -a -m "$commit_message"; then
echo "Error: Commit failed."
return 1
fi
if ! git push; then
echo "Error: Push failed."
return 1
fi
# Add a 5-second delay before running the post-push command
echo "Waiting for 5 seconds, well, just cuz..."
sleep 5
# Run the post-push command with arguments if specified
if [ -n "$post_push_command" ]; then
eval "$post_push_command $post_push_args"
fi
}A couple of notes:
- Parameter Parsing: The function iterates over the arguments passed to it. If an argument starts with —, it strips the — prefix and treats the rest as the command to be executed after a successful push. If a command has already been identified, subsequent arguments are treated as arguments for that command. Otherwise, the argument is treated as the commit message.
- Git Work Tree Check: The function checks if the current directory is a valid Git work tree using git rev-parse —is-inside-work-tree. If the check fails, it prints an error message and exits without running the post-push command.
Update submodules
Update all modules:
git submodule update --remoteUpdate specific module:
git submodule update --remote themes/hextraVimdiff
To move to the window to the right, use Ctr-w l.
If you are in window 1 and you want to pull in changes from window 0, use :diffget0. Replace 0 with the window number you want to pull from.
Chezmoi
To check in chezmoi changes, do the following:
chezmoi cd
chezmoi git add .
chezmoi git -- commit -m "Adding a real message"
chezmoi git -- pushGithub
Deleting Dependabot Workflows
It’s seems like you can’t delete Dependabot workflows if there are runs already.
You’ll see errors like:
[# 1]: GraphQL: Resource not accessible by personal access token (node.runs.nodes.0.checkSuite), Resource not accessible by personal access token (node.runs.nodes.1.checkSuite), Resource not accessible by personal access token (node.runs.nodes.2.checkSuite)If you have a .github/dependabot.yml, try deleting that first.
If that doesn’t work, first, make sure your Github CLI is tied to a classic token with repo and workflow rights.
Then chack if there have been Dependabot runs by looking on the website or running:
gh run list --workflow="Dependabot Updates" --repo <username>/<reponame>If you see a list of runs, run this to delete them:
gh run list --workflow="Dependabot Updates" --repo <username>/<reponame> --json databaseId --jq '.[].databaseId' | xargs -I {} gh api repos/<username>/<reponame>/actions/runs/{} -X DELETE