Skip to content

Instantly share code, notes, and snippets.

@Vaansh
Created September 23, 2021 17:41
Show Gist options
  • Save Vaansh/e07377a51d1616aae1fd406b9de7dd17 to your computer and use it in GitHub Desktop.
Save Vaansh/e07377a51d1616aae1fd406b9de7dd17 to your computer and use it in GitHub Desktop.
function to ease pushing changes made in remote repos for work/school
function gcp() {
echo "> New branch? [+used for remote branch] ('n' or 'no' for no, anything else for yes)"
read newbranch
if [ "${newbranch^^}" != "N" ] && [ "${newbranch^^}" != "NO" ]
then
echo "> Name of new branch: [+used for remote branch]"
read newbranchname
git checkout -b $newbranchname
fi
git status
echo "> Files to add:"
read filestoadd
git add $filestoadd
echo "> Enter commit message to add:"
read msg
git commit -m "${msg}" --no-verify
git push origin $(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment