Simple git commands
This commit is contained in:
@@ -1,16 +1,27 @@
|
||||
# shell-productivity
|
||||
|
||||
My zsh/bash productivity aliases / tools / scripts
|
||||
|
||||
## Installation
|
||||
|
||||
### Step 1
|
||||
|
||||
```bash
|
||||
cd ~
|
||||
git clone https://github.com/selimaj-dev/shell-productivity.git
|
||||
```
|
||||
|
||||
### Step 2 (zsh)
|
||||
|
||||
Add this into your `.zshrc`
|
||||
|
||||
```bash
|
||||
source ~/shell-productivity/rc.zsh
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
`ga` - **git add -A**
|
||||
`gp` - **git pull**
|
||||
`gc <message>` - **git commit -am <message>**
|
||||
`postpr` - **Done after a pull request is merged, switches to master and removes the pr branch and pulls**
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
# Silently remove any conflicting aliases
|
||||
unalias postpr 2>/dev/null
|
||||
unalias gc 2>/dev/null
|
||||
unalias ga 2>/dev/null
|
||||
unalias gp 2>/dev/null
|
||||
|
||||
# --- Functions ---
|
||||
|
||||
postpr() {
|
||||
# Save current branch
|
||||
local current_branch
|
||||
current_branch=$(git symbolic-ref --short HEAD)
|
||||
|
||||
if [[ "$current_branch" == "master" ]]; then
|
||||
echo "You are already on master!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Switch to master
|
||||
git checkout master || return 1
|
||||
|
||||
# Pull latest changes
|
||||
git pull origin master || return 1
|
||||
|
||||
# Delete previous branch locally
|
||||
git branch -d "$current_branch" || echo "Failed to delete branch $current_branch. Maybe unmerged changes?"
|
||||
|
||||
echo "Switched to master, pulled latest, and deleted branch $current_branch"
|
||||
}
|
||||
|
||||
gc() {
|
||||
git commit -am $1
|
||||
}
|
||||
|
||||
ga() {
|
||||
git add -A
|
||||
}
|
||||
|
||||
gp() {
|
||||
git pull
|
||||
}
|
||||
Reference in New Issue
Block a user