Compare commits
No commits in common. "9155daf9780555cfae58b121f379c12e1cffb9b4" and "30b6c49461ea9b00b916b3d70678e7fd38154321" have entirely different histories.
9155daf978
...
30b6c49461
2 changed files with 2 additions and 53 deletions
33
gitpurge
33
gitpurge
|
@ -1,33 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Ensure we're in a git repository
|
||||
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
||||
echo "Error: This script must be run inside a Git repository."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if git-filter-repo is installed
|
||||
if ! command -v git-filter-repo &> /dev/null; then
|
||||
echo "Error: git-filter-repo is not installed. Please install it first."
|
||||
echo "You can install it via pip: pip install git-filter-repo"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get a list of files that currently exist in the repository
|
||||
current_files=$(git ls-files)
|
||||
|
||||
# Create a file with the list of files to keep
|
||||
echo "$current_files" > files_to_keep.txt
|
||||
|
||||
# Use git-filter-repo to keep only the files that currently exist
|
||||
git filter-repo --paths-from-file files_to_keep.txt --force
|
||||
|
||||
# Remove the temporary file
|
||||
rm files_to_keep.txt
|
||||
|
||||
# Force push all branches
|
||||
git push origin --all --force
|
||||
|
||||
echo "Purge complete. All files not present in the local repo have been removed from all commits on all branches."
|
||||
echo "The changes have been force-pushed to the remote repository."
|
||||
|
22
up
22
up
|
@ -37,26 +37,12 @@ while IFS= read -r repo_path || [[ -n "$repo_path" ]]; do
|
|||
continue
|
||||
fi
|
||||
|
||||
# Check if 'origin' remote exists
|
||||
if ! git remote | grep -q '^origin$'; then
|
||||
echo "Remote 'origin' not found. Attempting to set it up..."
|
||||
# Try to guess the remote URL based on the directory name
|
||||
repo_name=$(basename "$repo_path")
|
||||
remote_url="https://git.sij.ai/sij/$repo_name.git"
|
||||
git remote add origin "$remote_url"
|
||||
echo "Added remote 'origin' with URL: $remote_url"
|
||||
fi
|
||||
|
||||
# Get the current branch
|
||||
current_branch=$(git rev-parse --abbrev-ref HEAD)
|
||||
|
||||
# Pull the latest changes from the repository
|
||||
echo "Pulling from $current_branch branch..."
|
||||
if ! git pull origin "$current_branch"; then
|
||||
echo "Failed to pull from origin. The remote branch might not exist or there might be conflicts."
|
||||
echo "Skipping further operations for this repository."
|
||||
continue
|
||||
fi
|
||||
git pull origin "$current_branch"
|
||||
|
||||
# Add changes to the Git index (staging area)
|
||||
echo "Adding all changes..."
|
||||
|
@ -72,11 +58,7 @@ while IFS= read -r repo_path || [[ -n "$repo_path" ]]; do
|
|||
|
||||
# Push changes to the remote repository
|
||||
echo "Pushing all changes..."
|
||||
if ! git push origin "$current_branch"; then
|
||||
echo "Failed to push changes. The remote branch might not exist."
|
||||
echo "Creating remote branch and pushing..."
|
||||
git push -u origin "$current_branch"
|
||||
fi
|
||||
git push origin "$current_branch"
|
||||
fi
|
||||
|
||||
echo "Update complete for $repo_path!"
|
||||
|
|
Loading…
Reference in a new issue