git scripts Команды для работы с Гит-ом и разными ветками в нем
Primary tabs
Forums:
В эту сборку входят в т.ч. команды:
Подключение
nano ~/.bashrc
И далее куда-то в конец:
if [ -f ~/.git-scripts.sh ]; then . ~/.git-scripts.sh fi
далее:
Перейдем в домашнюю директорию и создим файл:
> .git-scripts.sh
правим файл (копируем нужные функции из кода ниже) и вызываем:
. ~/.bashrc
-- чтобы новые функции были доступны
Скрипты .git-scripts.sh
Для копирования:
# Black 0;30 Dark Gray 1;30 # Red 0;31 Light Red 1;31 # Green 0;32 Light Green 1;32 # Brown/Orange 0;33 Yellow 1;33 # Blue 0;34 Light Blue 1;34 # Purple 0;35 Light Purple 1;35 # Cyan 0;36 Light Cyan 1;36 # Light Gray 0;37 White 1;37 YELLOW='\033[1;33m' CYAN='\033[0;35m' NC='\033[0m' function squashCurrentBranchCommits() { # set -x CURRENT_BRANCH="$(git symbolic-ref --short HEAD)" echo -e "${YELLOW}!!! Squash commits ${NC} for ${CURRENT_BRANCH}" echo -e "${YELLOW}Fetching master.....${NC}" git fetch origin master echo -e "${YELLOW}Fetching ${NC} current ${CURRENT_BRANCH}" git fetch origin ${CURRENT_BRANCH} echo -e "${YELLOW}Create master clone ${NC} master-new branch" git checkout -B master-new origin/master echo -e "${YELLOW}Merge ${NC} ${CURRENT_BRANCH} into master-new" git merge --squash origin/${CURRENT_BRANCH} git commit -m "${1:-Squash all previous commits}" echo -e "${YELLOW}Push --force! ${NC} master-new into ${CURRENT_BRANCH} " COMMAND="git push --force -u origin master-new:${CURRENT_BRANCH} ${2}" echo -e "${YELLOW} By Command: [[ ${NC} ${COMMAND} ${YELLOW} ]] ${NC} " bash -c "${COMMAND}" #${COMMAND} echo -e "${CYAN}Finished: Push --force ${NC} master-new into ${CURRENT_BRANCH} " echo -e "${YELLOW}Returning to ${NC} to ${CURRENT_BRANCH} (by git reset --hard) " git checkout ${CURRENT_BRANCH} git fetch origin ${CURRENT_BRANCH} git reset --hard origin/${CURRENT_BRANCH} echo -e "${YELLOW}Ready!${NC} ${CYAN}Show git status ${NC}: " git status # set +x } function fetchOriginAndResetHardToCurrentBranch() { # git fetch && ORIGIN_BRANCH="origin/"$(git symbolic-ref --short HEAD)"" echo -e "${YELLOW}Reset hard${NC} to ${ORIGIN_BRANCH}" git fetch && git reset --hard ${ORIGIN_BRANCH} } function rebOnActualMaster() { git fetch && git rebase origin/master } function contRebase() { git add . && git rebase --continue } # add commit push by one command function gacp() { git add . git commit -m "$1" git push }
- Log in to post comments
- 497 reads