CARVIEW |
Select Language
HTTP/2 200
date: Wed, 23 Jul 2025 14:32:45 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
etag: W/"27cfaec78a5ba40a644502d393618ef4"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=4bp2E9Vcu7VvOh2VQk8%2BbaMDZNLh0v7vlcmAw2vMtdHCuqq1ieAhRk9q7dyOPk6rbow7jZI0By0zTbhyu6mk%2B6xTufl0uQygTIdQ97mINHacV3AeG5j58l6NF2fnhqRdC0keHKBWqyepZluYx6JCZTzXOuuzV7smHje7OAh414VIUB9Vt9Qbzr6jw%2B77br6Q%2FDWmu6iVDoAQI5jA9z%2BYYPcnnRWipGo6HCRW7y2L%2FdNQGQsdjzbJnAWYNkhKinBkl6crcjKtXPhFGaxg2svKyw%3D%3D--7DTuHPOCknWV0zZB--Dk5Rj0mzXNnZcn9l8m%2Bk9Q%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.413320783.1753281164; Path=/; Domain=github.com; Expires=Thu, 23 Jul 2026 14:32:44 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Thu, 23 Jul 2026 14:32:44 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: BBE4:26221E:D431D5:FB157A:6880F28C
Bash script for checking local repositories for unpushed changes · GitHub
Show Gist options
Save codeinthehole/eb39e5b2238aca79ca68d48ded32d599 to your computer and use it in GitHub Desktop.
{{ message }}
Instantly share code, notes, and snippets.
Created
May 1, 2025 12:06
-
Star
0
(0)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
Save codeinthehole/eb39e5b2238aca79ca68d48ded32d599 to your computer and use it in GitHub Desktop.
Bash script for checking local repositories for unpushed changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Check the status of a folder of repos to see if there are any unpushed commits. | |
# | |
# This is intended to help migrate to a new laptop, where you want to check | |
# that there are no unpushed local commits before switching to the new machine. | |
# | |
# Needs `rg` and `fd` installed. | |
set -e | |
function check_all_repos { | |
local base_dir="$1" | |
repo_folders "$base_dir" | while read -r repo; do | |
folder_name="$(basename "$repo")" | |
echo "Checking repo '$folder_name'..." | |
cd "$repo" || exit 1 | |
check_repo | |
done | |
} | |
# Return the full paths to repos to examine. | |
function repo_folders { | |
fd -t d -d 1 . "$1" | |
} | |
# Check the status of the repo. | |
function check_repo { | |
# Update local index. | |
#git fetch 2> /dev/null | |
# Loop over local branches and check if they are in sync. | |
branches_to_check | while read -r branch; do | |
tracking_branch=$(remote_tracking_branch "$branch") | |
if [ -z "$tracking_branch" ]; then | |
echo " No tracking branch for '$branch'" >&2 | |
else | |
if is_out_of_sync "$branch" "$tracking_branch"; then | |
echo " Branch '$branch' is out of sync" >&2 | |
fi | |
fi | |
done | |
} | |
# Return the branches to check. | |
function branches_to_check { | |
# All branches except mainlines. | |
git branch --format='%(refname:short)' | rg -v "^(master|main|production)$" | |
} | |
# Print the name of the remote tracking branch (or an empty string). | |
function remote_tracking_branch { | |
if name=$(git rev-parse --abbrev-ref "$1@{upstream}" 2>/dev/null) | |
then | |
echo "$name" | |
else | |
echo "" | |
fi | |
} | |
# Test if the two branches are out of sync with each other. | |
function is_out_of_sync { | |
local local_branch="$1" | |
local tracking_branch="$2" | |
ahead=$(git rev-list --count "$local_branch...$tracking_branch") | |
behind=$(git rev-list --count "$tracking_branch...$local_branch") | |
[ "$ahead" -ne 0 ] || [ "$behind" -ne 0 ] | |
} | |
# Pass in the parent folder where the repos live. | |
check_all_repos "$HOME/Workspace/octo/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can’t perform that action at this time.