Skip to content

Instantly share code, notes, and snippets.

@codetot
Created April 10, 2021 15:19
Show Gist options
  • Save codetot/6f91965825bd8a5c5319e8af33ec1ea1 to your computer and use it in GitHub Desktop.
Save codetot/6f91965825bd8a5c5319e8af33ec1ea1 to your computer and use it in GitHub Desktop.
Update in each sub git folder
#!/bin/bash
git submodule foreach --recursive 'git fetch origin && git checkout master && git reset --hard origin/master'
@codetot
Copy link
Author

codetot commented Apr 10, 2021

# Uncommited Changes - Exit script if there uncommited changes
if ! git diff-index --quiet HEAD --; then
	echo "There are uncommited changes on this repository."
	exit 1
fi

@codetot
Copy link
Author

codetot commented Apr 10, 2021

# Remote exists - Exit script if remote does not exist
git ls-remote --exit-code ${remote} >/dev/null 2>&1
if [ $? -ne 0 ]
then
	echo "Remote ${remote} does not exist"
    exit 1
fi

@codetot
Copy link
Author

codetot commented Apr 10, 2021

# Branch exists - Exit script if local branch does not exist
git rev-parse -q --verify ${branch} >/dev/null 2>&1
if [ $? -ne 0 ]
then
    echo "Branch ${branch} exists"
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment