Skip to content

Instantly share code, notes, and snippets.

@Rami-Majdoub
Created June 28, 2023 13:04
Show Gist options
  • Save Rami-Majdoub/f2672e53ea4eea82034b9de6fce618ed to your computer and use it in GitHub Desktop.
Save Rami-Majdoub/f2672e53ea4eea82034b9de6fce618ed to your computer and use it in GitHub Desktop.
bash setup
merge-dev(){
current_branch="$(git branch --show-current)"
git checkout dev
git pull
git checkout "$current_branch"
git merge dev
}
gitbackup(){
today=$(date +%F-%H-%M)
current_branch="$(git branch --show-current)"
new_branch="${current_branch}-${today}"
git checkout -b "$new_branch"
git add .
git commit -m "backup"
last_commit="$(git rev-parse --short HEAD)"
git checkout "$current_branch"
git cherry-pick "$last_commit" --no-commit
}
gl(){
git log --decorate --oneline --max-count=5
}
gitlastcommit(){
current_branch="$(git branch --show-current)"
git checkout "$1"
last_commit="$(git rev-parse --short HEAD)"
git checkout "$current_branch"
git cherry-pick "$last_commit" --no-commit
git reset HEAD -- .
}
loadFileIfExist(){
[ -f $1 ] && . $1 || true
}
loadFolderIfExist(){
if [ -d $1 ] ; then
export PATH="$PATH:$1"
fi
}
loadFileIfExist ~/.bash_shortcuts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment